//
// ViewController.m
// NSMutableAttributedString
//
// Created by zhengbing on 6/30/16.
// Copyright © 2016 zhengbing. All rights reserved.
//
#import "ViewController.h"
@interface ViewController ()
@end
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
NSString *str = @"1234567";
NSMutableAttributedString *astr = [[NSMutableAttributedString alloc] initWithString:str];
[astr addAttribute:NSForegroundColorAttributeName value:[UIColor redColor] range:NSMakeRange(0, 2)];
[astr addAttribute:NSFontAttributeName value:[UIFont fontWithName:@"HelveticaNeue-Bold" size:30.0] range:NSMakeRange(3, 2)];
UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(100, 100, 100,100)];
label.attributedText = astr;
[self.view addSubview:label];
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
@end
NSMutableAttributedString属性文字
最新推荐文章于 2019-08-09 16:16:08 发布