NSMutableAttributedString属性文字
2016-06-30 16:53
288 查看
// // 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
相关文章推荐
- ios pod库更新到1.0或1.0.1之正确修改podfile文件
- iOS中URL Scheme是干嘛的
- iOS-资源大全
- ios关于百度地图框架地理编码的封装;
- iOS 如何缩小包体的大小 (静态库,IPA)
- iOS开发 将某个视图置于某视图之上
- [iOS 文本输入限制]限制输入特定字符串等
- iOS容易造成循环引用的三种场景,就在你我身边!
- iOS 时间处理
- iOS 文字转化成图片
- 开源游戏“2048”IOS移植版
- 3分钟实现iOS语言本地化/国际化(图文详解)
- iOS的三种多线程技术 对比分析
- IOS StoryBoard 中 alpha设置 导致subview中的控件也透明了
- iOS 创建PCH文件
- IOS集成到支付宝的步骤以及问题
- editActionsForRowAtIndexPath(iOS8) tableview编辑(删除、插入、移动)
- iOS支付宝1分钟集成,使用方法封装。超级好用
- iOS开发中下拉列表时放大列表顶部图片
- iOS内存管理:strong,weak,retain,assign