7.0系统以后的获取内容长度 的方法

来源:互联网 发布:天津知满天教育 编辑:程序博客网 时间:2024/05/16 09:12

CGSize size = [str sizeWithFont:[UIFont systemFontOfSize:FYFont_T4] constrainedToSize:CGSizeMake(180, 80) lineBreakMode:NSLineBreakByCharWrapping];

上面方法是 以前一直用的  但是7.0之后 就不能再用该方法
于是有了下面得方法  这方法能在6.0以后使用

UIFont *font = [UIFont systemFontOfSize:16];    CGSize size = CGSizeMake(320,2000);    CGRect labelRect = [str boundingRectWithSize:size options:(NSStringDrawingUsesLineFragmentOrigin)  attributes:[NSDictionary dictionaryWithObject:font forKey:NSFontAttributeName] context:nil];



0 0
原创粉丝点击