简体   繁体   中英

IOS 7.0 : How to change values of layer.cornerRadius of a Navigation Button

Is there a method to change the corner radius of the default button in the navigation bar ?

Or the best way is to create a custom button and set this button in the navigation bar.

NSDictionary *rightAttributes = [NSDictionary dictionaryWithObjectsAndKeys:
                                 [UIFont fontWithName:@"myFont" size:12.0], UITextAttributeFont,
                                 nil];

[self.navigationItem.rightBarButtonItem setTitleTextAttributes:rightAttributes forState:UIControlStateNormal];
//self.navigationItem.rightBarButtonItem.layer.cornerRadius = 5; //Don'tWork

Thanks.

You probably are going to want to create a BarButtonItem and then set that to the rightBarButtonItem with a custom view. Something like

 UIBarButtonItem *item = [[UIBarButtonItem alloc] initWithCustomView:aView];
    item.customView.layer.cornerRadius = 5;

Good luck.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM