自定义的UIButton的titleLabel与iOS 5的外观API
问题描述:
我想自定义标题标签的一个UIButton在外观上采用了全新的外观API,但没有发现任何东西,将工作。看来,下面的代码应该工作:自定义的UIButton的titleLabel与iOS 5的外观API
[[UILabel appearanceWhenContainedIn:[UIButton class], nil] setShadowOffset:CGSizeMake(0, 2)];
[[UILabel appearanceWhenContainedIn:[UIButton class], nil] setFont:[UIFont fontWithName:@"HelveticaNeue-CondensedBold" size:17]];
但我想UILabel实际上不是按钮的子视图。有任何想法吗?
答
你为什么不直接使用的UIButton
的titleLabel
属性修改标题标签?
button.titleLabel.font = [UIFont fontWithName:@"HelveticaNeue-CondensedBold" size:17];
button.titleLabel.shadowOffset = CGSizeMake(0, 2);
未经测试,但应该工作,对不对?
编辑: 你为什么不只是创建的UIButton的子类,并添加以下两行?
我遇到同样的问题。我认为按钮可能会覆盖这里的外观。 – wbyoung 2013-05-24 20:34:37