1. 修改界面背景为自定义图片
[self.view setBackgroundColor:[UIColor colorWithPatternImage:[UIImage imageNamed:@"Background_3.5.png"]]];
2. 修改导航栏字体颜色
NSDictionary *attributes=[NSDictionary dictionaryWithObjectsAndKeys:[UIColor whiteColor], NSForegroundColorAttributeName, nil];
[self.navigationController.navigationBar setTitleTextAttributes:attributes];
3. 修改导航栏按钮颜色
[self.navigationController.navigationBar setTintColor:[UIColor whiteColor]];
4. 修改导航栏背景为自定义图片
[self.navigationController.navigationBar setBackgroundImage:[UIImage imageNamed:@"NavigationBar.png"] forBarMetrics:UIBarMetricsDefault];
5. 修改状态栏字体颜色
先在info.plist中添加View controller-based status bar appearance字段,属性值设为NO
然后使用如下代码修改颜色
[[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent]; // 白色
[[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleDefault]; // 黑色
6. 使用RGB颜色修改控件背景
以UIButton为例
[settingsButton setBackgroundColor:[UIColor colorWithRed:194/255.0 green:19/255.0 blue:70/255.0 alpha:1]];
7. 使用自定义UITableViewCell
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *messageCellIdentifier = @"MessageCellIdentifier";
static BOOL nibsRegistered=NO;
if (!nibsRegistered)
{
UINib *nib=[UINib nibWithNibName:@"MessageTableViewCell" bundle:nil];
[tableView registerNib:nib forCellReuseIdentifier:messageCellIdentifier];
nibsRegistered=YES;
}
MessageTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:messageCellIdentifier];
if (cell==nil)
{
cell=[[[NSBundle mainBundle]loadNibNamed:@"MessageTableViewCell" owner:nil options:nil]lastObject];
}
[cell setFontSize:settings.fontSize];
NSInteger row = [indexPath row];
cell.senderLabel.text = [messageList objectAtIndex:row];
cell.messageTitleLabel.text = [messageList objectAtIndex:row];
cell.channelLabel.text = [channelList objectAtIndex:row];
return cell;
}
8. 让UITableViewCell背景透明
[self.postsTableView setBackgroundColor:[UIColor clearColor]];
9. 让UITableView分割线强制顶头显示
[self.postsTableView setSeparatorInset:UIEdgeInsetsZero];
10. 将UIImageView变为圆形且加上阴影,此例中imageView的大小为100*100,圆角设为高度的一半即可。另外需要将imageView放到container(UIView)中,再apply shadow layer
CALayer *layer=logoImageView.layer;
layer.masksToBounds=YES;
layer.cornerRadius=50;
layer.borderColor=[UIColor whiteColor].CGColor;
layer.borderWidth=3;
logoImageViewContainer.backgroundColor=[UIColor clearColor];
logoImageViewContainer.layer.shadowColor=[UIColor darkGrayColor].CGColor;
logoImageViewContainer.layer.shadowOpacity=0.8;
logoImageViewContainer.layer.shadowOffset=CGSizeMake(3, 3);
logoImageViewContainer.layer.shadowRadius=3;
logoImageViewContainer.layer.shadowPath=[UIBezierPath bezierPathWithRoundedRect:logoImageView.bounds cornerRadius:50].CGPath;
(未完待续)