码迷,mamicode.com
首页 > 移动开发 > 详细

IOS - UIView添加点击事件

时间:2015-07-07 23:02:08      阅读:524      评论:0      收藏:0      [点我收藏+]

标签:mystra   ios   gesture   点击事件   

UIView通过手势(Gesture-UITapGestureRecognizer)添加点击事件, 类似于UIButton的效果.
示例:

UIImageView *iKnowIcon = [CYResource loadImageView:@"free-question-once-more-i-know.png"];
iKnowIcon.top = questionIcon.top + scaleWidthWith320(200);
iKnowIcon.centerX = self.width / 2;
[self addSubview:iKnowIcon];
UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(dismiss)];
iKnowIcon.userInteractionEnabled = YES;
[iKnowIcon addGestureRecognizer:tap];

技术分享

版权声明:本文为博主原创文章,未经博主允许不得转载。

IOS - UIView添加点击事件

标签:mystra   ios   gesture   点击事件   

原文地址:http://blog.csdn.net/caroline_wendy/article/details/46791621

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