UILabel 에 set 된 Text의 Size 알기.
CGSize textSize = [[UILabel text] sizeWithFont:[UILabel font]];
drawTextInRect:
Draws the receiver’s text (or its shadow) in the specified rectangle.
#define strikeHeight 1.0
@implementation UIStrikeLabel
- (void)drawTextInRect:(CGRect)rect {
[super drawTextInRect:rect];
CGContextRef context = UIGraphicsGetCurrentContext();
CGSize textSize = [[self text] sizeWithFont:[self font]];
CGFloat strikeWidth = textSize.width;
CGContextFillRect(context, CGRectMake(0, rect.size.height/2, strikeWidth, strikeHeight));
}
@end
if([self strike]) {
CGSize textSize = [[self text] sizeWithFont:[self font]];
CGFloat strikeWidth = textSize.width;
CGContextFillRect(context, [self getStrikeRect:strikeWidth]);
}
switch ([self textAlignment]) {
default:
case UITextAlignmentLeft:
x = 0;
break;
case UITextAlignmentCenter:
x = (self.frame.size.width - strikeWidth) / 2.0;
break;
case UITextAlignmentRight:
x = self.frame.size.width - strikeWidth;
break;
}
'iPhone' 카테고리의 다른 글
Mac OS X 에서 hosts 파일 수정하기 (9) | 2011.01.14 |
---|---|
UIWebView 와 Application (App) 간의 통신 (15) | 2010.11.15 |
Debug 시에만 NSLog 출력 하기. (Debug 모드 구분하기) (0) | 2010.10.12 |
APNS(Apple Push Notification service) 인증서 파일(p12) 만들기 (0) | 2010.10.07 |
Application Loader에서 애플 개발자 계정 설정 변경 (6) | 2010.09.30 |
하나의 UIViewController 에서 두개 이상의 UITableView 를 표현하기 (2) | 2010.09.08 |
APNS 를 위한 Device Token 알아내기 (7) | 2010.09.06 |
HTML Page 에서 아이폰 키보드 자판 선택 (0) | 2010.08.18 |
IB에서 각 UIControlState 에서의 UIButton 의 이미지 설정 (0) | 2010.08.13 |
APXML Sample Source (10) | 2010.08.05 |