CGSize lblSize = [self.label1.text boundingRectWithSize:CGSizeMake(ScreenWidth - 75, MAXFLOAT) options:NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:15]} context:nil].size;
self.label2.frame = CGRectMake(65, 60, ScreenWidth - 65 - 10, lblSize.height + 20);
ScreenWidth - 75:此页面的宽度,自行定义
根据lblSize可以知道label1的字体的宽度和高度
网友评论