自定义UIBarButtonItem
2016-01-05 10:23
453 查看
//单个自定义按钮
UIButton *button =[UIButton
buttonWithType:UIButtonTypeCustom];
button.frame =CGRectMake(0,
0, 50,
50);
UIBarButtonItem*Button = [[UIBarButtonItem
alloc]
initWithCustomView:button];
self.navigationItem.leftBarButtonItem = Button;
//多个按钮
UIBarButtonItem *btn = [[UIBarButtonItem
alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemPlay
target:self
action:@selector(click:)];
UIBarButtonItem btnOne = [[UIBarButtonItem
alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemPause
target:self
action:@selector(click1:)];
[self.navigationItem
setRightBarButtonItems:[NSArray
arrayWithObjects:btn,btnOne,nil]];
//自定义View上随意放置button
UIView *view = [[UIView alloc]initWithFrame:CGRectMake(kWidth * 4 / 5, 0, 75, 30)];
//分享按钮
UIButton *sharebutton = [UIButton buttonWithType:(UIButtonTypeCustom)];
sharebutton.frame = CGRectMake(5, 0, 30, 30);
[view addSubview:sharebutton];
//收藏按钮
self.collectbutton = [UIButton buttonWithType:(UIButtonTypeCustom)];
self.collectbutton.frame = CGRectMake(45, 0, 30, 30);
[view addSubview:self.collectbutton];
UIBarButtonItem *collectItem = [[UIBarButtonItem alloc] initWithCustomView:view];
self.navigationItem.rightBarButtonItem =
collectItem;
UIButton *button =[UIButton
buttonWithType:UIButtonTypeCustom];
button.frame =CGRectMake(0,
0, 50,
50);
UIBarButtonItem*Button = [[UIBarButtonItem
alloc]
initWithCustomView:button];
self.navigationItem.leftBarButtonItem = Button;
//多个按钮
UIBarButtonItem *btn = [[UIBarButtonItem
alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemPlay
target:self
action:@selector(click:)];
UIBarButtonItem btnOne = [[UIBarButtonItem
alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemPause
target:self
action:@selector(click1:)];
[self.navigationItem
setRightBarButtonItems:[NSArray
arrayWithObjects:btn,btnOne,nil]];
//自定义View上随意放置button
UIView *view = [[UIView alloc]initWithFrame:CGRectMake(kWidth * 4 / 5, 0, 75, 30)];
//分享按钮
UIButton *sharebutton = [UIButton buttonWithType:(UIButtonTypeCustom)];
sharebutton.frame = CGRectMake(5, 0, 30, 30);
[view addSubview:sharebutton];
//收藏按钮
self.collectbutton = [UIButton buttonWithType:(UIButtonTypeCustom)];
self.collectbutton.frame = CGRectMake(45, 0, 30, 30);
[view addSubview:self.collectbutton];
UIBarButtonItem *collectItem = [[UIBarButtonItem alloc] initWithCustomView:view];
self.navigationItem.rightBarButtonItem =
collectItem;
相关文章推荐
- androidUI设计 .9.png 制作及去黑线
- Property 'sqlSessionFactory' or 'sqlSessionTemplate' are required
- Arduino—一款影响世界的开源硬件
- easyui中datagrid不加载问题
- iOS中使用UItableviewcell实现团购和微博界面的示例
- Cause: org.postgresql.util.PSQLException: ERROR: duplicate key value violates unique constraint "veh
- Query对象与DOM对象之间的转换方法
- Ngui 五种点击事件实现方式及在3d场景点透事件
- Failed to instantiate the default view controller for UIMainStoryboardFile
- iOS UI学习笔记(二)View的frame和bounds,center
- Leetcode: Shortest Distance from All Buildings
- 2016{太原UI设计师}郭文军讲解抠图须掌握的要点
- 《iOS Human Interface Guidelines》——Multitasking
- UIView 封装动画(补充)
- *Count Univalue Subtrees
- executeQuery、executeUpdate 和 execute
- 【iOS系列】- iOS吸附效果的实现 之 UICollectionView的使用全解
- 发布Qt Quick桌面应用程序的方法
- 《深入理解OSGi:Equinox原理、应用与最佳实践》笔记_1_运行最简单的bundlehelloworld
- 《深入理解OSGi:Equinox原理、应用与最佳实践》笔记_1_运行最简单的bundlehelloworld