【问题标题】:How to get on screen text inside UILabel if text does not fit frame?如果文本不适合框架,如何在 UILabel 中显示屏幕文本?
【发布时间】:2015-09-18 18:07:51
【问题描述】:
UILabel * yourLabel = [[UILabel alloc] initWithFrame....];
yourLabel.adjustsFontSizeToFitWidth = NO;
yourLabel.lineBreakMode = UILineBreakModeTailTruncation;
yourLabel.text = @"Some long text that not fit frame, many words, many symbols";

在屏幕上我看到“一些不是...的长文本” 如何获取字符串"Some long text that not" or tail "fit frame, many words, many symbols"

【问题讨论】:

    标签: ios objective-c nsstring uilabel cgrect


    【解决方案1】:

    请在一行中添加您的代码并检查它

    [yourLabel sizeToFit];
    

    【讨论】:

      【解决方案2】:

      试试这个代码

      yourLabel.adjustsFontSizeToFitWidth = NO;
      yourLabel.lineBreakMode = UILineBreakModeWordWrap;
      yourLabel.numberOfLines = 0;
      

      【讨论】:

      • 我不需要更改字体大小。我需要得到 NSString * fetText = @"Some long text that not"; and NSString * tailText = @"适合框架,很多单词,很多符号";
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2010-10-02
      • 2017-10-31
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多