oc的自适应高度

2019-03-27  本文已影响0人  神一样的队友

- (CGSize)depaendWithContent:(NSString*)content font:(UIFont*)font  withSize:(CGSize)size

{

    //返回size

    NSMutableParagraphStyle *Style = [[NSMutableParagraphStyle alloc]init];

    Style.lineBreakMode = NSLineBreakByWordWrapping;

    NSDictionary *attributes1 = @{NSFontAttributeName:font, NSParagraphStyleAttributeName:Style.copy};

    CGSize Size = [content boundingRectWithSize:size options:NSStringDrawingUsesLineFragmentOrigin attributes:attributes1 context:nil].size;

    returnSize;

}

上一篇下一篇

猜你喜欢

热点阅读