#pragma mark 快速创建一个item
- (UIBarButtonItem *)itemWithNormal:(NSString *)normal highlighted:(NSString *)highlighted selector:(SEL)selector {
// 初始化按钮
UIButton *button = [[[UIButton alloc] init] autorelease];
button.title.font = [UIFont systemFontOfSize:10];
// 设置按钮背景图片
UIImage *normalImg = [UIImage imageNamed:normal];
UIImage *highlightedImg = [UIImage imageNamed:highlighted];
button.bounds = CGRectMake(, , normalImg.size.width, normalImg.size.height);
[button setBackgroundImage:normalImg forState:UIControlStateNormal];
[button setBackgroundImage:highlightedImg forState:UIControlStateHighlighted];
// 监听按钮点击
[button addTarget:self action:selector forControlEvents:UIControlEventTouchUpInside];
// 初始化item
return [[[UIBarButtonItem alloc] initWithCustomView:button] autorelease];
}
 // 设置左边
self.navigationItem.leftBarButtonItem = [self itemWithNormal:@"left.png"
highlighted:@"leftHigh.png" selector:@selector(send)]; // 设置右边
self.navigationItem.rightBarButtonItem = [self itemWithNormal:@"right.png"
highlighted:@"rightHigh.png" selector:@selector(refresh)];
 // 设置cell的背景色
UIView *bg = [[[UIView alloc] init] autorelease];
bg.backgroundColor = [UIColor colorWithRed:0.95 green:0.95 blue:0.95 alpha:];
cell.backgroundView = bg;
 // 设置cell选中的背景
UIView *selectdBg = [[[UIView alloc] init] autorelease];
selectdBg.backgroundColor = [UIColor colorWithRed:0.85 green:0.85 blue:0.85 alpha:];
cell.selectedBackgroundView = selectdBg;
 //设置按钮的标题和颜色
[btn setNormalBg:@"normal.png" andHightlighted:@"highlight.png"];
[btn setTitle@"title" forState:UIControlStateNormal];
[btn setTitleColor:[UIColor balckColor] forState:UIControlStateNormal];
UIButton *button = [[[UIButton alloc] init] autorelease];
//字体大小
button.title.font = [UIFont systemFontOfSize:];
//自动对齐
button.title.textAlignment = NSTextAlignmentCenter;
//设置背景图片
[button setBackgroundImage:[UIImage resizeImage:@"image.png"] forState:UIControlStateNormal];
 UIButton *btn = [[UIButton alloc] init];
UIImage *imageNormal = [UIImage imageNamed:"@image.png"];
[btn setBackgroundImage:imageNormal forState:UIControlStateNormal];
UIImage *highLight = [UIImage imageNamed:"@high.png"];
[btn setBackgroundImage:imageNormal forState:UIControlStateHighlighted];
UIBarButtonItem *item = [[[UIBarButtonItem alloc] initWithCustomView:btn] autorelease];
viewController.navigationItem.rightBarButtonItem = item;
 
 
 
 
 
 
 
 
 
 
05-14 15:44