自定义导航栏多个按钮

UIToolbar* tools = [[UIToolbar alloc] initWithFrame:CGRectMake(0, 0, 150, 45)];

[tools setTintColor:[self.navigationController.navigationBar tintColor]];

[tools setAlpha:[self.navigationController.navigationBar alpha]];

NSMutableArray* buttons = [[NSMutableArray alloc] initWithCapacity:2];

UIBarButtonItem *anotherButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemSearch

target:self action:@selector(clickSettings:)];

UIBarButtonItem *anotherButton1 = [[UIBarButtonItem alloc] initWithTitle:@"Edit" style:UITabBarSystemItemContacts

target:self action:@selector(clickEdit:)];

[buttons addObject:anotherButton];

[buttons addObject:anotherButton1];

[tools setItems:buttons animated:NO];

UIBarButtonItem *myBtn = [[UIBarButtonItem alloc] initWithCustomView:tools];

self.navigationItem.rightBarButtonItem = myBtn;

时间: 2024-10-19 02:23:34

自定义导航栏多个按钮的相关文章

自定义导航栏的返回按钮

UIBarButtonItem *left = [[UIBarButtonItem alloc] initWithTitle:@"返回3" style:UIBarButtonItemStyleDone target:self action:@selector(onBack:)]; self.navigationItem.leftBarButtonItem = left; //另外自定义的按钮后 就不能使用自带的右滑返回手势,参考//http://blog.sina.com.cn/s/b

iOS 自定义导航栏的返回按钮

UIBarButtonItem * item  =    [UIBarButtonItem appearance]; UIImage* image = [UIImage imageNamed:@"back_icon"]; [item setBackButtonBackgroundImage:[image resizableImageWithCapInsets:UIEdgeInsetsMake(0, image.size.width, 0, 0)] forState:UIControlS

实际iOS编程中遇到的自定义导航栏按钮,导致手势返回失效的解决方法

1\在实际编程过程中往往需要自定义导航栏上面的按钮,也就用: - (instancetype)initWithCustomView:(UIView *)customView; 但用了这个方法后可能会导致iOS7,8的手势返回失效,解决方法就是在自定义的导航栏的viewDidLoad方法中添加如下代码 注意:只有用系统的导航栏,或者继承于系统的导航栏才可以用Push方法,并且自带返回手势. - (void)viewDidLoad { [super viewDidLoad]; __weak type

自定义导航栏标题按钮

自定义标题栏按钮 @implementation SNTitleButton - (id)initWithFrame:(CGRect)frame { self = [super initWithFrame:frame]; if (self) { //图片居中 self.imageView.contentMode = UIViewContentModeCenter; //字体居右 self.titleLabel.textAlignment = NSTextAlignmentRight; //字体

自定义导航栏返回按钮文字

自定义导航栏返回按钮文字 by 伍雪颖 navigationItem.backBarButtonItem = UIBarButtonItem(title: "返回", style: UIBarButtonItemStyle.Plain, target: nil, action: nil)

解决 ios7.0 以后自定义导航栏左边按钮靠右的问题

解决 ios7.0 以后自定义导航栏左边按钮靠右的问题 www.111cn.net 编辑:edit02_lz 来源:转载 最近开发了一个ios的app,在ios7.0+出现自定义导航栏左边按钮出现靠右的情况,后来自己解决了,解决办法如下 1.自定义按钮  代码如下 复制代码 //左按钮UIButton *leftBtn = [[UIButton alloc]initWithFrame:RectWithPara(-20, 0, 44, 44)];[leftBtn addTarget:self ac

IOS 自定义导航栏标题和返回按钮标题

IOS中自定义导航栏标题: UILabel *titleText = [[UILabel alloc] initWithFrame: CGRectMake(160, 0, 120, 50)]; titleText.backgroundColor = [UIColor clearColor]; titleText.textColor=[UIColor whiteColor]; [titleText setFont:[UIFont systemFontOfSize:17.0]]; [titleTex

自定义导航栏按钮 baseViewController中写!

// 自定义导航栏"返回按钮" - (void)initNaviBackBtn {     UIButton *backBtn = [UIButtonbuttonWithType:UIButtonTypeCustom];     backBtn.frame = CGRectMake(0, 0, 50, 22);     [backBtn setImage:[UIImageimageNamed:@"backBtn"] forState:UIControlStateNo

自定义导航栏返回时的滑动手势处理

现在使用默认模板创建的iOS App都支持手势返回功能,如果导航栏的返回按钮是自定义的那么则会失效,也可以参考这里手动设置无效. if ([self.navigationController respondsToSelector:@selector(interactivePopGestureRecognizer)]) { self.navigationController.interactivePopGestureRecognizer.enabled = NO; } 如果是因为自定义导航按钮而导