ios6中仿ios7导航按钮
#pragma mark 仿iOS7ButtonItem- (id)initWithTitle:(NSString *)title addTarget:(id)target action:(SEL)action{if (self = ){
// 创建一个普通按钮并设置按钮样式 UIButton *button = ; ; ; ; ; button.titleLabel.font = ; CGSize size = ; button.bounds = (CGRect){CGPointZero, size.width + 10, size.height};
button.contentHorizontalAlignment = iOS7 ? UIControlContentHorizontalAlignmentRight : UIControlContentHorizontalAlignmentLeft; // 设置按钮事件处理 ;
// 将item初始化为上述按钮样式 self = [ initWithCustomView:button]; } return self;}
#pragma mark 仿iOS7返回按钮- (id)initWithBackButtonTitle:(NSString *)title addTarget:(id)target action:(SEL)action{ if (self = ){ // 创建一个普通按钮并设置按钮样式 UIButton *button = ;
// 蓝色返回箭头 UIImage *normal = ; ;
// 按钮文字及属性 ; ; ;
// 按钮布局 button.imageEdgeInsets = UIEdgeInsetsMake(0, iOS7 ? -15 : 4, 0, 0); button.titleEdgeInsets = UIEdgeInsetsMake(0, iOS7 ? -10 : 6, 0, 0);
CGFloat width = .width + 20; button.bounds = (CGRect){CGPointZero, width, normal.size.height};
// 设置按钮事件处理 ;
// 将item初始化为上述按钮样式 self = [ initWithCustomView:button]; } return self;}
页:
[1]