ios 获取字符串所需要占用的label的高度

//    设置字体大小

    UIFont *fnt=[UIFont systemFontOfSize:16];

    NSDictionary *attribute = @{NSFontAttributeName: fnt};

//     CGSize retSize; 全局变量

    retSize = [Remark[0] boundingRectWithSize:CGSizeMake(SCREEN_WIDTH, 0)

                                             options:\

                      NSStringDrawingTruncatesLastVisibleLine |

                      NSStringDrawingUsesLineFragmentOrigin |

                      NSStringDrawingUsesFontLeading

                                          attributes:attribute

                                             context:nil].size;

    

     labels1 = [[UILabel alloc]initWithFrame:CGRectMake(10, Lastview.frame.size.height/2+SCREEN_WIDTH/10, SCREEN_WIDTH-20, retSize.height)];

    labels1.numberOfLines = 0;

    labels1.font =fnt;

   

    labels1.textColor =[UIColor colorWithWhite:0.663 alpha:1.000];

    labels1.text = Remark[0];

    [Lastview addSubview:labels1];

 

posted on 2016-02-04 16:41  popper小P  阅读(134)  评论(0编辑  收藏  举报