UILabel *hah = [[UILabel alloc]initWithFrame:CGRectMake(100, 15, 100, 0)];
hah.font = [UIFont systemFontOfSize:100];
hah.text = @"fffff";
hah.backgroundColor = [UIColor blueColor];
[hah sizeToFit];
[label addSubview:hah];
CGRect titleRect = [@"fffffffawgawdpumkjff" boundingRectWithSize:CGSizeMake(MAXFLOAT, 20) options:NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:100]} context:nil];
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(2.0 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
NSLog(@"---- %f %f",titleRect.size.width,titleRect.size.height);
NSLog(@"----pointSize: %f height: %f ascender: %f descender: %f capHeight: %f xHeight: %f lineHeight: %f leading: %f",hah.font.pointSize,hah.frame.size.height,hah.font.ascender,hah.font.descender,hah.font.capHeight,hah.font.xHeight,hah.font.lineHeight,hah.font.leading);
});
测试发现 单行 .font.lineHeight == titleRect.size.height
ascender + descender = lineHeight
苹果的descender 与 descent的值是不一样的
1688086-dc9d65ae561579ed.png
网友评论