iOS UIKit

iOS中给UIimageView添加UITapGestureRe

2017-04-11  本文已影响34人  彬至睢阳

UIImageView* headerImVC = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, 82, 82)];

headerImVC.image = [UIImage imageNamed:@"head.png"];

headerImVC.userInteractionEnabled = YES;//默认为NO,需要改为YES,否则会触发不了手势

UITapGestureRecognizer* tap = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(didiHeadImVC)];

tap.numberOfTapsRequired = 1;

[headerImVC addGestureRecognizer:tap];

   [view addSubview:headerImVC];

上一篇 下一篇

猜你喜欢

热点阅读