在代码中对button上的字进行设置,我们可以通过:
m_addButton.titleLabel.font = [UIFont systemFontOfSize: 7]; m_addButton.titleLabel.textColor = [UIColor blackColor]; m_addButton.titleLabel.textAlignment = UITextAlignmentRight;
但是改变上面的字的时候不能用 m_addButton.titleLabel.text = @"Add Stuff";
而是要通过 [m_addButton setTitle:@"1111" forState: UIControlStateNormal];
[selfsetImage:[UIImageimageNamed:@"ic_home_page_unlike"]forState:UIControlStateNormal];
效果:[selfsetBackgroundImage:[UIImageimageNamed:@"ic_home_page_unlike"] forState:UIControlStateNormal];
效果:
本文介绍了在iOS应用开发中如何使用Objective-C设置UIButton的文字属性和图片资源。具体包括字体大小、颜色、对齐方式及按钮标题和背景图片的设置方法。
684

被折叠的 条评论
为什么被折叠?



