uibutton点击按钮时title变大 松开时变小
2016-02-23 19:16
633 查看
结合 NSMutableAttributedString的各种属性可以做很多事情
下面只是一种小情况
UIButton *button = [UIButton buttonWithType:(UIButtonTypeCustom)];
button.frame = CGRectMake(100, 100, 100, 30);
button.backgroundColor = [UIColor redColor];
NSMutableAttributedString *str = [[NSMutableAttributedString alloc] initWithString:@"压缩图片"];
[str addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:12.0] range:NSMakeRange(0, 4)];
[button setAttributedTitle:str forState:(UIControlStateNormal)];
NSMutableAttributedString *str1 = [[NSMutableAttributedString alloc] initWithString:@"压缩图片"];
[str1 addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:20.0] range:NSMakeRange(0, 4)];
[button setAttributedTitle:str1 forState:(UIControlStateHighlighted)];
[self.view addSubview:button];
下面只是一种小情况
UIButton *button = [UIButton buttonWithType:(UIButtonTypeCustom)];
button.frame = CGRectMake(100, 100, 100, 30);
button.backgroundColor = [UIColor redColor];
NSMutableAttributedString *str = [[NSMutableAttributedString alloc] initWithString:@"压缩图片"];
[str addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:12.0] range:NSMakeRange(0, 4)];
[button setAttributedTitle:str forState:(UIControlStateNormal)];
NSMutableAttributedString *str1 = [[NSMutableAttributedString alloc] initWithString:@"压缩图片"];
[str1 addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:20.0] range:NSMakeRange(0, 4)];
[button setAttributedTitle:str1 forState:(UIControlStateHighlighted)];
[self.view addSubview:button];
相关文章推荐
- Kinect NuiInitialize failed
- 错误:The request sent by the client was syntactically incorrect的解决
- Implement Queue using Stacks
- Volley源码解析<三> Request请求
- 使用requireJS加载不符合AMD规范的js文件:shim的使用方式和实现原理
- UIAlertView, UIAlertViewController
- [Sequence Alignment Methods] Smith–Waterman algorithm
- Arduino VS 树莓派:哪个才是你的菜?
- Leetcode 62: Unique Paths
- UIView的layoutSubviews和drawRect方法何时调用
- TI BLE 1.4.1 协议栈 定义128位UUID的方法
- [转]Handler MessageQueue Looper消息循环原理分析
- 21. RequireJS
- UIBezierPath精讲
- 24.UINavigation 和 UIViewController 的各种关系分析
- confluence创建文件报错 can not create to file /tmp/xxx Errcode:28,引出的 df命令高级用法
- 23.UITableView如何改变contentSize
- ZOJ 3333 Guess the Price(模拟)
- mac下通过xcodebuild使用oclint
- UIAlertController使用