大佬教程收集整理的这篇文章主要介绍了在iOS 7.0.3中使用boundingRectWithSize的UILabel渲染问题,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
示例2:文本在1行(而不是2)上绘制,并且不进行自动换行,仅尾部截断.
这是我在上面列出的两个iOS版本中使用的代码.
@H_944_13@CGSize boundingSize = CGSizeMake(214,9999); CGRect boundingRect = CGRectZero; [self.nameLabel setnumberOfLines:2]; // for iOS7 if([self.place.placename respondsToSELEctor:@SELEctor(boundingRectWithSize:options:attributes:context:)]){ NSMutableParagraphStyle *paragraphStyle = [[NSParagraphStyle defaultParagraphStyle] mutableCopy]; [paragraphStyle setLineBreakmode:NSLineBreakByWordWrapping]; boundingRect = [self.place.placename boundingRectWithSize:boundingSize options:NSStringDrawingUsesLineFragmentOrigin attributes:[NSDictionary DictionaryWithObjectsAndKeys: self.nameLabel.font,NSFontAttributename,paragraphStyle,NSParagraphStyleAttributename,nil] context:nil]; }else{ // pre iOS7 CGSize size = [self.place.placename sizeWithFont:self.nameLabel.font consTrainedToSize:boundingSize lineBreakmode:NSLineBreakByWordWrapping]; boundingRect = CGRectMake(0,size.width,size.height); } [self.nameLabel setFrame:CGRectMake(CGRectGetMaxX(self.photoImageView.framE)+15,CGRectGetMinY(self.photoImageView.framE),boundingRect.size.width,boundingRect.size.height)]; [self.nameLabel setText:[place placename]];
有任何想法吗?提前致谢.
以上是大佬教程为你收集整理的在iOS 7.0.3中使用boundingRectWithSize的UILabel渲染问题全部内容,希望文章能够帮你解决在iOS 7.0.3中使用boundingRectWithSize的UILabel渲染问题所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。