本篇算是给我这个没记性的人写个小工具书吧 欢迎同样记不住的人收藏😂(想起或者用到就追加)
设置状态栏颜色
在info.plist中设置
View controller-based status bar appearance (最后一项)(NO 默认是YES)
然后在代码中添加
[UIApplication sharedApplication].statusBarStyle = UIStatusBarStyleLightContent;
layer 常用属性
layer.backgroundColor = [UIColor cyanColor].CGColor; // 给图层添加背景色
layer.contents = (id)[UIImage imageNamed:@"view_BG.png"].CGImage; // 给图层添加背景图片
layer.cornerRadius = 8; // 将图层的边框设置为圆脚 (值为对象宽一半为圆形)
layer.masksToBounds = YES; // 隐藏边界
layer.borderWidth = 5; // 给图层添加一个有色边框
layer.borderColor = [UIColor colorWithRed:0.52 green:0.09 blue:0.07 alpha:1].CGColor; //边框颜色
layer.shadowOffset = CGSizeMake(0, 3); // 设置阴影的偏移量
layer.shadowRadius = 10.0; // 设置阴影的半径
layer.shadowColor = [UIColor blackColor].CGColor; // 设置阴影的颜色为黑色
layer.shadowOpacity = 0.9; // 设置阴影的不透明度
layer.anchorPoint = CGPointMake(1, 1);//锚点为原点
UITextField 左视图 (用作padding)
//人工增加内边距
UIView * textFieldPlaceHolderPaddingView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 20, TextFeild.bounds.size.height)];
//将Padding视图添加到文本框左视图
publishDynamicTextFeild.leftView = publishDynamicPlaceHolderPaddingView;
publishDynamicTextFeild.leftViewMode = UITextFieldViewModeAlways;
KVC 强写 UITextField.placeholder
placeholder是一个Label其他属性可遵循UILabel
[textField setValue:[UIColor grayColor] forKeyPath:@"_placeholderLabel.textColor"];//文本颜色
[passWordTextField setValue:@0.5 forKeyPath:@"_placeholderLabel.alpha"];//文本透明度
[passWordTextField setValue:@1 forKeyPath:@"_placeholderLabel.textAlignment"];//文本居中
UIButton 常用属性
[button setBackgroundImage:[UIImage imageNamed:@""] forState:(UIControlStateNormal)];//按钮背景图片
[button setContentHorizontalAlignment:UIControlContentHorizontalAlignmentLeft];//按钮标题对其方式
[button setExclusiveTouch:YES];//解决同时按两个
UINavigationController 常用属性
navigationController.navigationBar.barTintColor = [UIColor blackColor];//颜色
navigationItem.titleView = titleLabel;//标题视图
navigationController.navigationBar addSubview:imageView];//导航栏增加视图