您的位置:首页 > 产品设计 > UI/UE

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];
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: