码迷,mamicode.com
首页 > 其他好文 > 详细

关于NavigationItem.rightBarButtonItem设置

时间:2014-05-23 22:05:08      阅读:274      评论:0      收藏:0      [点我收藏+]

标签:style   blog   c   tar   http   a   

转自:http://blog.csdn.net/zhuzhihai1988/article/details/7701998

第一种:

 

UIImage *searchimage=[UIImage imageNamed:@"search.png"];

    UIBarButtonItem *barbtn=[[UIBarButtonItem alloc] initWithImage:nil style:UIBarButtonItemStyleDone target:self action:@selector(searchprogram)];    

    barbtn.image=searchimage;

    self.navigationItem.rightBarButtonItem=barbtn;

这种设置出来的外观不好控制

第二种:

 

UIButton*rightButton = [[UIButtonalloc]initWithFrame:CGRectMake(0,0,30,30)];

    [rightButtonsetImage:[UIImageimageNamed:@"search.png"]forState:UIControlStateNormal];

    [rightButtonaddTarget:selfaction:@selector(searchprogram)forControlEvents:UIControlEventTouchUpInside];

   UIBarButtonItem*rightItem = [[UIBarButtonItemalloc]initWithCustomView:rightButton];

    [rightButton release];

   self.navigationItem.rightBarButtonItem= rightItem;

    [rightItem release];

这种图片将填满button,大小可控

第三种:

UIBarButtonItem *anotherButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemBookmarks target:self action:@selector(methodtocall:) ]; 

如何让navigationItem.rightBarButtonItem隐藏消失?

self.navigationItem.rightBarButtonItem=nil;

即可实现

关于NavigationItem.rightBarButtonItem设置,布布扣,bubuko.com

关于NavigationItem.rightBarButtonItem设置

标签:style   blog   c   tar   http   a   

原文地址:http://www.cnblogs.com/wangpei/p/3737141.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!