Can I set the `attributedText` property of `UILabel`

后端 未结 8 918
长发绾君心
长发绾君心 2020-12-22 21:52

Can I set the attributedText property of a UILabel object? I tried the below code:

UILabel *label = [[UILabel alloc] init];
label.a         


        
8条回答
  •  刺人心
    刺人心 (楼主)
    2020-12-22 22:17

    UIFont *font = [UIFont boldSystemFontOfSize:12];
    NSDictionary *fontDict = [NSDictionary dictionaryWithObject: font forKey:NSFontAttributeName];
    NSMutableAttributedString *attrString = [[NSMutableAttributedString alloc] initWithString:@" v 1.2.55" attributes: fontDict];
    
    UIFont *fontNew = [UIFont boldSystemFontOfSize:17];
    NSDictionary *fontDictNew = [NSDictionary dictionaryWithObject: fontNew forKey:NSFontAttributeName];
    NSMutableAttributedString *attrStringNew = [[NSMutableAttributedString alloc] initWithString:@“Application” attributes: fontDictNew];
    [attrStringNew appendAttributedString: attrString];
    self.vsersionLabel.attributedText = attrStringNew;
    

提交回复
热议问题