@property(nonatomic,strong)UIBarButtonItem *mapBtn;//第一個(gè)
@property(nonatomic,strong)UIBarButtonItem *messageBtn;//第二個(gè)
//第一個(gè)
-(UIBarButtonItem *)mapBtn{
if (!_mapBtn) {
UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];
[btn addTarget:self action:@selector(buttonClick:) forControlEvents:UIControlEventTouchUpInside];
[btn setImage:[UIImage iconWithInfo:TBCityIconInfoMake(@"\U0000e637", 23, __kColorGray)] forState:UIControlStateNormal];
[btn sizeToFit];
_mapBtn = [[UIBarButtonItem alloc] initWithCustomView:btn];
}
return _mapBtn;
}
//第二個(gè)
-(UIBarButtonItem *)messageBtn{
if (!_messageBtn) {
UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];
[btn addTarget:self action:@selector(buttonClick:) forControlEvents:UIControlEventTouchUpInside];
[btn setImage:[UIImage iconWithInfo:TBCityIconInfoMake(@"\U0000e69a", 25, __kColorGray)] forState:UIControlStateNormal];
[btn sizeToFit];
_messageBtn = [[UIBarButtonItem alloc] initWithCustomView:btn];
}
return _messageBtn;
}
//顯示
- (void)viewDidLoad {
[super viewDidLoad];
//間隙
UIBarButtonItem *fixedSpaceBarButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFixedSpace target:nil action:nil];
fixedSpaceBarButtonItem.width = 12;
self.navigationItem.rightBarButtonItems = @[self.messageBtn,fixedSpaceBarButtonItem,self.mapBtn];
}
iOS學(xué)習(xí)之導(dǎo)航欄右側(cè)放置兩個(gè)按鈕
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書(shū)系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書(shū)系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。
推薦閱讀更多精彩內(nèi)容
- {"keys":[{"key2":"余華","key":"活著","url":"https://www.jians...
- 前言:這段時(shí)間一直在準(zhǔn)備校招的東西,所以一晃眼都好長(zhǎng)時(shí)間沒(méi)更新了,這段時(shí)間準(zhǔn)備的稍微好那么一點(diǎn)點(diǎn),還是覺(jué)得準(zhǔn)備歸準(zhǔn)...
- iOS功能 iOS 如何跳轉(zhuǎn)到系統(tǒng)設(shè)置里的指定子功能界面 http://blog.csdn.net/jingfa1...
- PS:以記筆記的方式,匯總一些android基礎(chǔ)知識(shí)。 1、android 四種啟動(dòng)模式 2、activity或f...