RectFrame (width = 170, height = 30)에 텍스트 (텍스트는 "0 %", 글꼴 크기 = 30)를 그리는 방법이 있습니다.iOS NSString drawInRect는 항상 RectFrame의 맨 아래에 텍스트를 그립니다.
/* Draw String IOS 7 up */
-(void) drawString: (CGRect) contextRect withStr: (NSString *) string {
NSMutableParagraphStyle *textStyle = [[NSMutableParagraphStyle defaultParagraphStyle] mutableCopy];
textStyle.lineBreakMode = NSLineBreakByWordWrapping;
textStyle.alignment = NSTextAlignmentCenter;
UIFont *font = [UIFont systemFontOfSize:_textSize];
UIColor* textColor = [UIColor grayColor];
NSDictionary* stringAttrs = @{NSFontAttributeName:font, NSParagraphStyleAttributeName:textStyle, NSForegroundColorAttributeName:textColor};
[string drawInRect:contextRect withAttributes:stringAttrs];
}
나는 이미지 결과를 게시 할 수 없습니다하지만 결과는 텍스트가 프레임의 맨 아래에 약간의 픽셀을 그려되어 있지만 바닥은 아무리 (하단 프레임 텍스트 하단 일치) 미세 없으며, 프레임과 텍스트의 크기를 모두 조정합니다. 프레임 상단 아래에 항상 "어딘가"로 그려지는 아이디어가 있습니까?