iOS开发iOS

iOS:导航栏NavigationItem添加Button方法

2017-04-19  本文已影响3148人  iOS技术小卒

iOS开发中经常要在在导航栏添加回退、或者搜索、或者保存按钮。下面就是自定义按钮的方法。

Xcode截图 模拟器

UIButton *leftbutton=[[UIButton alloc]initWithFrame:CGRectMake(0, 0, 80, 20)];

//[leftbutton setBackgroundColor:[UIColor blackColor]];

[leftbutton setTitle:@"保存" forState:UIControlStateNormal]

UIBarButtonItem *rightitem=[[UIBarButtonItem alloc]initWithCustomView:leftbutton];

self.navigationItem.rightBarButtonItem=rightitem;

上一篇 下一篇

猜你喜欢

热点阅读