按钮的常见方法
[btn imageForState:UIControlStateNormal];
btn.currentImage;
[btn backgroundImageForState:UIControlStateNormal];
btn.currentBackgroundImage;
[btn titleForState:UIControlStateNormal];
btn.currentTitle;
按钮的图片什么情况下会被自动渲染成蓝色?
- UIButton的样式是
UIButtonTypeSystem
- 图片的状态是
UIControlStateSelected
在Storyboard、xib中让UILabel等控件的文字换行显示
按钮的内边距属性
button.titleEdgeInsets = UIEdgeInsetsMake(0, 10, 0, 0);
button.imageEdgeInsets = UIEdgeInsetsMake(0, 10, 0, 0);
button.contentEdgeInsets = UIEdgeInsetsMake(0, -15, 0, 0);
设置状态栏样式
[[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent]
/**
* 设置状态栏为白色
*/
- (UIStatusBarStyle)preferredStatusBarStyle
{
return UIStatusBarStyleLightContent;
}
修改UITextField的光标颜色
textField.tintColor = [UIColor whiteColor];
利用attributedPlaceholder修改UITextField的占位文字颜色
if (textField.placeholder.length == 0) return;
NSMutableDictionary *attributes = [NSMutableDictionary dictionary];
attributes[NSForegroundColorAttributeName] = [UIColor redColor];
textField.attributedPlaceholder = [[NSAttributedString alloc] initWithString:textField.placeholder attributes:attributes];