iOS > Test API about getting text size.

It’s new API to get the size of text for iOS7.

NSDictionary *attributes = @{NSFontAttributeName:[UIFont systemFontOfSize:14]};
CGSize titleSize = [str sizeWithAttributes:attributes];
NSLog(@"New API > string width->%f, height->%f",titleSize.width, titleSize.height);

It’s deprecated API to get the size of text on iOS7.

titleSize = [str sizeWithFont:[UIFont systemFontOfSize:14]];
NSLog(@"Old API > string width->%f, height->%f",titleSize.width, titleSize.height);
# New API > string width->70.322000, height->16.702000
# Old API > string width->71.000000, height->17.000000

The new api is correct more then the old api. but the new api is only able to use on iOS7. if you support the under version of iOS 7. you should use the old one.

댓글 남기기

이메일은 공개되지 않습니다. 필수 입력창은 * 로 표시되어 있습니다