UILabel
UITableView
背景色
代码语言:javascript复制tableView.backgroundColor = UIColor(hexString: "#f3f3f3", alpha: 0.6);
分割线
代码语言:javascript复制tableView.separatorStyle = UITableViewCellSeparatorStyle.SingleLine;
內边距
代码语言:javascript复制self.tableView.contentInset = UIEdgeInsetsMake(0, 0, 64, 0);
UITableViewCell
右侧标记
代码语言:javascript复制cell.accessoryType = UITableViewCellAccessoryType.DisclosureIndicator;
取消选中样式
代码语言:javascript复制cell.selectionStyle = UITableViewCellSelectionStyle.None;
UIButton
标题
代码语言:javascript复制statusButton.setTitle("已完成", forState: UIControlState.Normal);
secButton.setTitle("已评价", forState: UIControlState.Disabled);
secButton.enabled = false;
UINavigationBar(全局设置)
Swift示例
代码语言:javascript复制let appear = UINavigationBar.appearance();
//设置Item的样式
appear.tintColor = UIColor.whiteColor();
//设置bar的颜色
appear.barTintColor = UIColor(red: 39/255, green: 157/255, blue: 244/255, alpha: 1.0);
//设置背景色(不透明时没用,因为barTintColor在backgroundColor的上一层)
appear.backgroundColor = UIColor(red: 39/255, green: 157/255, blue: 244/255, alpha: 1.0);
//去掉navigationBar下的黑线
appear.setBackgroundImage(UIImage(), forBarMetrics: UIBarMetrics.Default)
appear.shadowImage = UIImage();
//设置标题样式
appear.titleTextAttributes = [NSForegroundColorAttributeName: UIColor.whiteColor(),NSFontAttributeName: UIFont.systemFontOfSize(18)];
OC示例
代码语言:javascript复制UINavigationBar *appear = [UINavigationBar appearance];
appear.tintColor = [UIColor clearColor];
appear.barTintColor = [UIColor colorWithRed:52.0/255 green:146.0/255 blue:233.0/255 alpha:1];
appear.backgroundColor = [UIColor colorWithRed:52.0/255 green:146.0/255 blue:233.0/255 alpha:1];
[appear setBackgroundImage:[[UIImage alloc] init] forBarMetrics:UIBarMetricsDefault];
appear.shadowImage = [[UIImage alloc] init];
appear.titleTextAttributes = [NSDictionary dictionaryWithObjectsAndKeys:
[UIColor whiteColor],NSForegroundColorAttributeName,
[UIFont systemFontOfSize:18.0],NSFontAttributeName,nil
];
UITabBar(全局设置)
OC示例
代码语言:javascript复制UITabBar *tabbarAppear = [UITabBar appearance];
tabbarAppear.tintColor = [UIColor colorWithRed:56.0/255 green:173.0/255 blue:255.0/255 alpha:1];
UINavigationBar(页面设置)
设置标题颜色(OC)
代码语言:javascript复制//选择自己喜欢的颜色
UIColor * color = [UIColor whiteColor];
//这里我们设置的是颜色,还可以设置shadow等,具体可以参见api
NSDictionary * dict = [NSDictionary dictionaryWithObject:color forKey:NSForegroundColorAttributeName];
//大功告成
self.navigationController.navigationBar.titleTextAttributes = dict;
设置透明(Swift)
后两句是核心
代码语言:javascript复制//设置Navigationbar
self.navigationController.navigationBar.barStyle = UIBarStyle.BlackTranslucent;
self.navigationController.navigationBar.tintColor = UIColor.whiteColor();
self.navigationController.navigationBar.setBackgroundImage(UIImage(), forBarMetrics: UIBarMetrics.Default)
self.navigationController.navigationBar.shadowImage = UIImage();
UISearchBar(全局设置)
Swift示例
代码语言:javascript复制let searchBarAppear = UISearchBar.appearance();
//searchBarAppear.translucent = false;
searchBarAppear.backgroundColor = UIColor.clearColor();
searchBarAppear.tintColor = ZJ_Color.天空蓝;
searchBarAppear.barTintColor = UIColor(red: 240/255, green: 240/255, blue: 240/255, alpha: 1.0);
searchBarAppear.layer.borderColor = UIColor(hexString: "#ffffff")!.CGColor;
searchBarAppear.layer.borderWidth = 0;
searchBarAppear.backgroundImage = UIImage();