본문 바로가기

Program/iOS

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.pointSizekCGEncodingMacRoman);

    CGContextSetTextDrawingMode(context, kCGTextFill);

    CGContextSetRGBFillColor(context, 1001);

    

    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

'Program > iOS' 카테고리의 다른 글

Mac - Show Finder Hiding File  (0) 2012.01.03
Memory Leak  (3) 2011.12.15
iOS5 - "armv6" UPLOAD Error  (2) 2011.11.04
Mac - Inactive memory can be slow to free up  (1) 2011.09.26
iOS mpmovieplayercontroller  (4) 2011.08.31