zoukankan      html  css  js  c++  java
  • (CGSize)sizeWithFont:(UIFont *)font constrainedToSize:(CGSize)size lineBreakMode:(NSLineBreakMode)lineBreakMode

    UIFont *font = [UIFont systemFontOfSize:12];

    CGSize size = [text sizeWithFont:font constrainedToSize:CGSizeMake(150.0f, 1000.0f) lineBreakMode:UILineBreakModeCharacterWrap];

    获取字符串在指定的size内(宽度超过150,则换行)所需的的实际高度和宽度. 
    将获取的宽度和高度用于UILabel 
    UILabel *bubbleText = [[UILabel alloc] initWithFrame:CGRectMake(21.0f, 14.0f, size.width+10, size.height+10)];

    bubbleText.backgroundColor = [UIColor clearColor];

    bubbleText.font = font;

    bubbleText.numberOfLines = 0;

    bubbleText.lineBreakMode = UILineBreakModeCharacterWrap; 

    bubbleText.text = text;

  • 相关阅读:
    文本数据清洗总结
    PyTorch
    PyTorch
    NLP
    TF
    TF
    TF
    cairosvg
    word2vec 实现 影评情感分析
    Gensim
  • 原文地址:https://www.cnblogs.com/paideblogs/p/5310817.html
Copyright © 2011-2022 走看看