适配iOS 10的问题
2016-09-14 本文已影响555人
PPAbner
Xcode8 及iOS10适配问题汇总
很详细2016-11-01
10之前 10.pngXcode没来得及更新,自己手机更新到10了,运行项目,自己负责的代码出现这样情况,我用的是YYLabel!!求助!!!
附代码:
CGFloat introHeight = [self getMessageHeight:introStr andLabel:self.proIntroductLB1];
self.proIntroductLB1.frame = CGRectMake(85, introductH+8, ScreenWidth-100, introHeight);
/**
* 获取lb的高度(默认字体13,行间距8,lb宽ScreenWidth-100)
* @param mess lb.text
* @param lb (YYLabel *)label
* @return lb的高度
*/
-(CGFloat)getMessageHeight:(NSString *)mess andLabel:(YYLabel *)lb
{
NSMutableAttributedString *introText = [[NSMutableAttributedString alloc] initWithString:mess];
introText.yy_font = FontSet(13);
introText.yy_lineSpacing = 8;
lb.attributedText = introText;
CGSize introSize = CGSizeMake(ScreenWidth-100, CGFLOAT_MAX);
YYTextLayout *layout = [YYTextLayout layoutWithContainerSize:introSize text:introText];
lb.textLayout = layout;
CGFloat introHeight = layout.textBoundingSize.height;
return introHeight;
}