本篇算是給我這個(gè)沒(méi)記性的人寫(xiě)個(gè)小工具書(shū)吧 歡迎同樣記不住的人收藏??(想起或者用到就追加)
設(shè)置狀態(tài)欄顏色
在info.plist中設(shè)置
View controller-based status bar appearance (最后一項(xiàng))(NO 默認(rèn)是YES)
然后在代碼中添加
[UIApplication sharedApplication].statusBarStyle = UIStatusBarStyleLightContent;
layer 常用屬性
layer.backgroundColor = [UIColor cyanColor].CGColor; // 給圖層添加背景色
layer.contents = (id)[UIImage imageNamed:@"view_BG.png"].CGImage; // 給圖層添加背景圖片
layer.cornerRadius = 8; // 將圖層的邊框設(shè)置為圓腳 (值為對(duì)象寬一半為圓形)
layer.masksToBounds = YES; // 隱藏邊界
layer.borderWidth = 5; // 給圖層添加一個(gè)有色邊框
layer.borderColor = [UIColor colorWithRed:0.52 green:0.09 blue:0.07 alpha:1].CGColor; //邊框顏色
layer.shadowOffset = CGSizeMake(0, 3); // 設(shè)置陰影的偏移量
layer.shadowRadius = 10.0; // 設(shè)置陰影的半徑
layer.shadowColor = [UIColor blackColor].CGColor; // 設(shè)置陰影的顏色為黑色
layer.shadowOpacity = 0.9; // 設(shè)置陰影的不透明度
layer.anchorPoint = CGPointMake(1, 1);//錨點(diǎn)為原點(diǎn)
UITextField 左視圖 (用作padding)
//人工增加內(nèi)邊距
UIView * textFieldPlaceHolderPaddingView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 20, TextFeild.bounds.size.height)];
//將Padding視圖添加到文本框左視圖
publishDynamicTextFeild.leftView = publishDynamicPlaceHolderPaddingView;
publishDynamicTextFeild.leftViewMode = UITextFieldViewModeAlways;
KVC 強(qiáng)寫(xiě) UITextField.placeholder
placeholder是一個(gè)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];//按鈕標(biāo)題對(duì)其方式
[button setExclusiveTouch:YES];//解決同時(shí)按兩個(gè)
UINavigationController 常用屬性
navigationController.navigationBar.barTintColor = [UIColor blackColor];//顏色
navigationItem.titleView = titleLabel;//標(biāo)題視圖
navigationController.navigationBar addSubview:imageView];//導(dǎo)航欄增加視圖