使用iOS 5的Appearance API自定义UIButton的titleLabel

时间:2012-08-01 19:26:50

标签: iphone objective-c ios ios5

我正在尝试使用新的外观API在UIButton中自定义标题标签的外观,但是没有找到任何可行的东西。似乎以下代码应该起作用:

[[UILabel appearanceWhenContainedIn:[UIButton class], nil] setShadowOffset:CGSizeMake(0, 2)];
[[UILabel appearanceWhenContainedIn:[UIButton class], nil] setFont:[UIFont fontWithName:@"HelveticaNeue-CondensedBold" size:17]];

但我认为UILabel实际上并不是按钮的子视图。有什么想法吗?

1 个答案:

答案 0 :(得分:0)

为什么不使用titleLabel的{​​{1}}属性直接修改标题标签?

UIButton

未经测试,但这应该有效,对吧?

编辑: 为什么不直接创建UIButton的子类并添加这两行?