NSAttributedString ignores Autoshrink and numberOfLines for UILabel (iOS 6)

后端 未结 3 1555
臣服心动
臣服心动 2021-01-31 09:01

I have UILabel with number of lines = 2 system font size = 15 minimum font size = 8 Line break mode - Truncate tail

When I set long text which have type NSString for UI

3条回答
  •  野趣味
    野趣味 (楼主)
    2021-01-31 09:28

    NSMutableAttributedString *muAtrStr = [[NSMutableAttributedString alloc]initWithString:@"2"];
    NSAttributedString *atrStr = [[NSAttributedString alloc]initWithString:@"\ndays" attributes:@{NSFontAttributeName : [UIFont fontWithName:@"HelveticaNeue-Bold" size:8]}];
    [muAtrStr appendAttributedString:atrStr];
    self.lbl.numberOfLines = 0;
    [self.lbl setAttributedText:muAtrStr];
    

提交回复
热议问题