导航栏:
//设置导航栏的标题
self.navigationItem.title = @"First";
//设置导航栏的背景色
// self.navigationController.navigationBar.tintColor = [UIColor redColor];
//设置导航栏的背景图片
[self.navigationController.navigationBar setBackgroundImage:[UIImage imageNamed:@"tabBar.png"]forBarMetrics:UIBarMetricsDefault];
//自定义导航栏的标题
UILabel *titleText = [[UILabel alloc] initWithFrame: CGRectMake(140, 0, 200, 50)];
titleText.backgroundColor = [UIColor clearColor];
titleText.textColor=[UIColor whiteColor];
[titleText setFont:[UIFont systemFontOfSize:37.0]];
[titleText setText:@"XXX"];
self.navigationItem.titleView=titleText;
[titleText release];
// 自定义返回按钮
UIBarButtonItem *backItem=[[UIBarButtonItem alloc]init];
backItem.title=@"后退";
backItem.tintColor=[UIColor redColor];
self.navigationItem.backBarButtonItem = backItem;
[backItem release];
//去掉tableView中的线
[self.tableView setSeparatorStyle:UITableViewCellSeparatorStyleNone];
//自定义右边按钮
UIBarButtonItem * rightButton = [[UIBarButtonItem alloc]
initWithTitle:@"回到首页"
style:UIBarButtonItemStyleBordered
target:self
action:@selector(gotolast)];
rightButton.image=[UIImage imageNamed:@"right_button.png"];
rightButton.tintColor=[UIColor brownColor];
//自定义cell
//定义一个类继承UITableViewCell,实现文件修改如下
#import "MyCell.h"
@implementation MyCell
@synthesize label;
- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
if (self) {
// Initialization code
label = [[UILabel alloc]initWithFrame:CGRectMake(250, 10, 70, 20)];
label.backgroundColor = [UIColor clearColor];
[self addSubview:label];
[label release];
UIImageView *img = [[UIImageView alloc]initWithFrame:CGRectMake(125, 10, 44, 44)];
img.image = [UIImage imageNamed:@"star.png"];
[self addSubview:img];
[img release];
}
return self;
}
标签栏:
//设置标签栏的背景图片
self.tabBar.backgroundImage = [UIImage imageNamed:@"tabBar.png"];
//设置tabBarItem的标题
self.tabBarItem.title = @"first";
//设置tabBarItem的图标
self.tabBarItem.image = [UIImage imageNamed:@"1.png"];
//设置tabBarItem选中和未选中的图片
[self.tabBarItem setFinishedSelectedImage:[UIImage imageNamed:@"star.png"] withFinishedUnselectedImage:[UIImage imageNamed:@"1.png"]];
//隐藏标签栏
self.tabBarController.tabBar.hidden = YES;
//显示标签栏
self.tabBarController.tabBar.hidden = YES;
//设置标签栏的背景色:
self.tabBar.tintColor = [UIColor purpleColor];