4000 IOS开发 导航条…
2016-12-12 23:02
323 查看
前几天被这个问题搞得头昏,转不过来弯。突然想起可以定义两个按钮放在同一个位置。点击一次就添加另一个按钮.
- (void) handleBtn1: (id) sender {
NSLog(@"现在是按钮2事件");
UIButton
*btn = [UIButton
buttonWithType:UIButtonTypeCustom];
[btn setTitle:@"按钮1"
forState:UIControlStateNormal];
[btn addTarget:self action:@selector(handleBtn2:) forControlEvents:UIControlEventTouchUpInside];
btn.frame
= CGRectMake(0, 0, 40, 20);
self.navigationItem.rightBarButtonItem
= [[UIBarButtonItem
alloc]initWithCustomView:btn];
}
- (void) handleBtn2: (id) sender {
NSLog(@"现在是按钮1事件");
UIButton
*btn = [UIButton
buttonWithType:UIButtonTypeCustom];
[btn setTitle:@"按钮2"
forState:UIControlStateNormal];
[btn addTarget:self action:@selector(handleBtn1:) forControlEvents:UIControlEventTouchUpInside];
btn.frame
= CGRectMake(0, 0, 40, 20);
self.navigationItem.rightBarButtonItem
= [[UIBarButtonItem
alloc]initWithCustomView:btn];
}
- (void) viewDidLoad {
UIButton
*btn = [UIButton
buttonWithType:UIButtonTypeCustom];
[btn setTitle:@"淡出"
forState:UIControlStateNormal];
[btn addTarget:self action:@selector(handleBtn1:) forControlEvents:UIControlEventTouchUpInside];
btn.frame
= CGRectMake(0, 0, 40, 20);
self.navigationItem.rightBarButtonItem
= [[UIBarButtonItem
alloc]initWithCustomView:btn];
}
- (void) handleBtn1: (id) sender {
NSLog(@"现在是按钮2事件");
UIButton
*btn = [UIButton
buttonWithType:UIButtonTypeCustom];
[btn setTitle:@"按钮1"
forState:UIControlStateNormal];
[btn addTarget:self action:@selector(handleBtn2:) forControlEvents:UIControlEventTouchUpInside];
btn.frame
= CGRectMake(0, 0, 40, 20);
self.navigationItem.rightBarButtonItem
= [[UIBarButtonItem
alloc]initWithCustomView:btn];
}
- (void) handleBtn2: (id) sender {
NSLog(@"现在是按钮1事件");
UIButton
*btn = [UIButton
buttonWithType:UIButtonTypeCustom];
[btn setTitle:@"按钮2"
forState:UIControlStateNormal];
[btn addTarget:self action:@selector(handleBtn1:) forControlEvents:UIControlEventTouchUpInside];
btn.frame
= CGRectMake(0, 0, 40, 20);
self.navigationItem.rightBarButtonItem
= [[UIBarButtonItem
alloc]initWithCustomView:btn];
}
- (void) viewDidLoad {
UIButton
*btn = [UIButton
buttonWithType:UIButtonTypeCustom];
[btn setTitle:@"淡出"
forState:UIControlStateNormal];
[btn addTarget:self action:@selector(handleBtn1:) forControlEvents:UIControlEventTouchUpInside];
btn.frame
= CGRectMake(0, 0, 40, 20);
self.navigationItem.rightBarButtonItem
= [[UIBarButtonItem
alloc]initWithCustomView:btn];
}
相关文章推荐
- IOS开发之----strong和weak (…
- ios 第三方苹果开发库之ASIHTTPReq…
- iOS 开发strong weak assign copy
- iOS开发- 蓝牙后台接收数据
- iOS 音频开发之CoreAudio
- iOS 分享新浪微博开发通知
- ios开发--app 同时支持iphon…
- IOS开发之 ---- I…
- iOS开发-调用google map并显…
- iOS开发:使用Settings Bundl…
- ios开发 UITableCell 可重用问题
- SQLibs iOS开发常用代码库
- ios 开发环境 复制的另一台电脑
- <转> iOS开发网络篇—文件的上传
- iOS 更改导航条上返回按钮的标题
- IOS 开发 loadView 和 viewDidLoad…
- iOS 开发资源汇总《转》
- iOS 开发常用尺寸
- iOS 关于音频开发
- <转> iOS开发网络篇—大文件的…