首页 > 其他 > 详细

关于NavigationItem.rightBarButtonItem设置

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

转自: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设置

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

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!