UIColor *color1=[UIColor colorWithRed:155/255 green:255/255 blue:255/255 alpha:1];//方法1,使用 静态方法创建color _view1.backgroundColor=color1; UIColor *color2=[[UIColor alloc] initWithRed:222/255 green:213/255 blue:221/255 alpha:1];//方法2,使用 实例方法 创建color [_view2 setBackgroundColor:color2];
self.navigationController.navigationBar.backgroundColor = [UIColor colorWithRed:253/255.0 green:50/255.0 blue:58/255.0 alpha:1.0];
!!!!要加.0切记
//[UIColor colorWithRed:143/255.0 green:186/255.0 blue:55/255.0 alpha:1.0];//呼伦贝尔草原绿
//设置UIbutton的文字颜色
[btn setTitleColor:[UIColor blackColor]forState:UIControlStateNormal];
//设置UIbutton的文字大小和背景颜色
btn.titleLabel.font = [UIFont systemFontOfSize: 14.0];
[btn setBackgroundColor: [UIColor blueColor]];
//有些时候我们想让UIButton的title居左对齐,我们设置
btn.contentHorizontalAlignment = UIControlContentHorizonAlignmentLeft;
但是问题又出来,此时文字会紧贴到做边框,我们可以设置
btn.contentEdgeInsets = UIEdgeInsetsMake(0,10, 0, 0);
使文字距离做边框保持10个像素的距离。
//将图层的边框设置为圆脚 myWebView.layer.cornerRadius = 8; myWebView.layer.masksToBounds = YES; //给图层添加一个有色边框 myWebView.layer.borderWidth = 5; myWebView.layer.borderColor = [[UIColor colorWithRed:0.52 green:0.09 blue:0.07 alpha:1] CGColor];