Setting font on NSAttributedString on UITextView disregards line spacing

后端 未结 5 1283
执笔经年
执笔经年 2020-12-08 03:35

I\'m trying to set an attributed string to a UITextView in iOS 6. The problem is, if I attempt to set the font property on the attributed string, the line spacing is ignored

5条回答
  •  长情又很酷
    2020-12-08 04:23

    Attributed String Programming Guide:

    UIFont *font = [UIFont fontWithName:@"Palatino-Roman" size:14.0];
    NSDictionary *attrsDictionary = [NSDictionary dictionaryWithObject:font
                                    forKey:NSFontAttributeName];
    NSAttributedString *attrString = [[NSAttributedString alloc] initWithString:@"strigil" attributes:attrsDictionary];
    

    Update: I tried to use addAttribute: method in my own app, but it seemed to be not working on the iOS 6 Simulator:

    NSLog(@"%@", textView.attributedText);

    The log seems to show correctly added attributes, but the view on iOS simulator was not display with attributes.

提交回复
热议问题