day3

来源:互联网 发布:淘宝的微波炉是真品吗 编辑:程序博客网 时间:2024/04/30 14:27

按钮的常见方法

// 获得内部imageView的图片[btn imageForState:UIControlStateNormal];btn.currentImage;// 获得背景图片[btn backgroundImageForState:UIControlStateNormal];btn.currentBackgroundImage;// 获得内部titleLabel的文字[btn titleForState:UIControlStateNormal];btn.currentTitle;

按钮的图片什么情况下会被自动渲染成蓝色?

  • UIButton的样式是UIButtonTypeSystem
  • 图片的状态是UIControlStateSelected

在Storyboard、xib中让UILabel等控件的文字换行显示

  • Option + 回车键

按钮的内边距属性

// 设置内部titleLabel的内边距button.titleEdgeInsets = UIEdgeInsetsMake(0, 10, 0, 0);// 设置内部imageView的内边距button.imageEdgeInsets = UIEdgeInsetsMake(0, 10, 0, 0);// 设置整体内容的内边距button.contentEdgeInsets = UIEdgeInsetsMake(0, -15, 0, 0);

设置状态栏样式

  • 使用UIApplication
    • 设置Info.plist

// 白色状态栏[[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent]
  • 使用UIViewController
// 控制器中实现对应的方法/** *  设置状态栏为白色 */- (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];
0 0