iOS - TextField 자간 조정
CustomTextField.h
#import <Foundation/Foundation.h>
@interface CustomTextField : UITextField {
}
@end
CustomTextField.m
#import "CustomTextField.h"
@implementation CustomTextField
- (void) drawTextInRect:(CGRect)rect
{
CGRect bounds = [self bounds];
const char *result = [self.text UTF8String];
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextSelectFont(context, "Arial", self.font.pointSize, kCGEncodingMacRoman);
CGContextSetTextDrawingMode(context, kCGTextFill);
CGContextSetRGBFillColor(context, 1, 0, 0, 1);
CGContextSetCharacterSpacing(context, 1); // <-----파라미터를 수정해주시면 됩니다.
CGContextTranslateCTM(context, 0, bounds.size.height + 5);
CGContextScaleCTM(context, 1, -1);
CGContextShowTextAtPoint(context, 0, rect.size.height/2, result, strlen(result));
}
@end