导航栏按钮 [英] Navigation Bar Button

查看:173
本文介绍了导航栏按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我在导航栏中放置两个右边的按钮时,这两个按钮是可见的但是它们有一个顶部边框意味着我不想要那个边框。

When I am putting two right bar buttons in my navigation bar at that time those two buttons are visible but they have a top border means I don't want that border.

我在框架中创建这些按钮并将该框架分配给导航栏。如何隐藏该边框?

I am creating those buttons in my frame and assigning that frame to the navigation bar. How do I hide that frame border?

我的代码如下:

UIBarButtonItem *btnAdd = [[UIBarButtonItem alloc] initWithTitle:@"Add"
                                                               style:UIBarButtonItemStyleBordered
                                                              target:self
                                                              action:@selector(Add)];

UIBarButtonItem *btnEdit = [[UIBarButtonItem alloc] initWithTitle:@"Edit"
                                                                style:UIBarButtonItemStyleBordered
                                                               target:self
                                                               action:@selector(Edit)];

UIToolbar *rightToolBar = [[UIToolbar alloc] initWithFrame:CGRectMake(0, 0, 100, 46)];
rightToolBar.backgroundColor = [UIColor clearColor];
rightToolBar.tintColor = [UIColor colorWithRed:40.0/255.0 green:48.0/255.0 blue:51.0/255.0 alpha:0.0];
NSArray *buttonsRight = [NSArray arrayWithObjects:btnEdit, btnAdd, nil];
[rightToolBar setItems:buttonsRight];

self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:rightToolBar];


推荐答案

使用此

UIBarButtonItem *btnAdd = [[UIBarButtonItem alloc] initWithTitle:@"Add"
                                                               style:UIBarButtonItemStylePlain
                                                              target:self
                                                              action:@selector(Add)];

而非使用

style:UIBarButtonItemStyleBordered

这篇关于导航栏按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆