Navigation Bar Button

这一生的挚爱 提交于 2019-12-12 09:25:21

问题


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?

My code is as below:

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];

回答1:


Use this

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

instead of using

style:UIBarButtonItemStyleBordered



回答2:


Set frameborder="0" in Frame tag it will disable frame.

And if you link a button and it shows the border then use css to rewrite the link properties:

a:link {color:#FF0000;}      /* unvisited link */
a:visited {color:#00FF00;}  /* visited link */
a:hover {color:#FF00FF;}  /* mouse over link */
a:active {color:#0000FF;}  /* selected link */

For help read http://www.w3schools.com/css



来源:https://stackoverflow.com/questions/5725327/navigation-bar-button

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!