适用于IOS6.0
UIImage *image2 = [UIImage imageNamed:@"header_left_back_normal"];
CGFloat top = 0; // 顶端盖高度
CGFloat bottom = 0 ; // 底端盖高度
CGFloat left = 15; // 左端盖宽度
CGFloat right = 15; // 右端盖宽度
UIEdgeInsets insets = UIEdgeInsetsMake(top, left, bottom, right);
image2 = [image2 resizableImageWithCapInsets:insets resizingMode:UIImageResizingModeTile];
// UIImageResizingModeStretch:拉伸模式,通过拉伸UIEdgeInsets指定的矩形区域来填充图片
// UIImageResizingModeTile:平铺模式,通过重复显示UIEdgeInsets指定的矩形区域来填充图片
UIButton *backBtn2 = [UIButton buttonWithType:UIButtonTypeCustom];
backBtn2.frame = CGRectMake(0, 100, screenWidth, 29);
[backBtn2 setBackgroundImage:image2 forState:UIControlStateNormal];
[backBtn2 setBackgroundImage:image2 forState:UIControlStateSelected];
[backBtn2 addTarget:self action: @selector(customDefaultBackButtonClick) forControlEvents: UIControlEventTouchUpInside];
[backBtn2 setTitle:@"讨论组" forState:UIControlStateNormal];
[backBtn2.titleLabel setFont:[UIFont fontWithName:@"Arial" size:13]];
[self.view addSubview:backBtn2];