UIImageView上添加Button不能响应点击事件
2016-04-15 15:06
567 查看
UIImageView *backImageView = [[UIImageView alloc]initWithFrame:CGRectMake(0, self.view.frame.size.height-UITABBAR_HEIGHT-216-39, 320, 43) ];
[backImageView setUserInteractionEnabled:YES];//使添加其上的button有点击事件
[backImageView setImage:[UIImage imageNamed:@"navigationBar.png"]];
[backScroll addSubview:backImageView];
UIButton *loginButton = [UIButton alloc];
[loginButton setFrame:CGRectMake(10, 0, 40, 43)];
[loginButton setTitle:@"hello" forState:UIControlStateNormal];
[loginButton addTarget:self action:@selector(loginOrLogout) forControlEvents:UIControlEventTouchUpInside];
[backImageView addSubview:loginButton];
来源:http://blog.sina.com.cn/s/blog_9c3c519b0100yhfh.html
[backImageView setUserInteractionEnabled:YES];//使添加其上的button有点击事件
[backImageView setImage:[UIImage imageNamed:@"navigationBar.png"]];
[backScroll addSubview:backImageView];
UIButton *loginButton = [UIButton alloc];
[loginButton setFrame:CGRectMake(10, 0, 40, 43)];
[loginButton setTitle:@"hello" forState:UIControlStateNormal];
[loginButton addTarget:self action:@selector(loginOrLogout) forControlEvents:UIControlEventTouchUpInside];
[backImageView addSubview:loginButton];
来源:http://blog.sina.com.cn/s/blog_9c3c519b0100yhfh.html
相关文章推荐
- 属性动画基础之ValueAnimator
- 属性动画基础之ValueAnimator
- android stuidio 代理设置
- String、StringBuilder和StringBuffer的区别
- ueditor配置方法
- iOS获取UUID,并使用keychain存储,将账号密码存到keychain中
- UIBezierPath 贝尔曲线
- UIAlertController 的使用
- 【UFLDL-notes of attached materials(to be continued)】
- ICPCCamp 2016 Day 3 - F Similar Subsequence (dp)
- Android自动化测试(UiAutomator)简要介绍
- 编译器判断优化(__builtin_expect)
- iOS UIWindow 窗口
- cocoaPods 安装第三库出现错误(target overrides the `USER_HEADER_SEARCH_PATHS` build setting defined in `Pods/)
- guava、protobuf、guice浅析
- LeetCode 288. Unique Word Abbreviation(单词缩写)
- Core Graphics 定制UIVIew 处理图片
- Android学习笔记——Bluetooth的使用
- iPad如何使用UIPopoverController
- android UI进阶之style和theme的使用