iOS菜鸟开发 UIView,UIImageView 的点击事件

让 View,ImageView整体有点击效果,和 Button一样 

 

UITapGestureRecognizer *uitgp = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(ddd)];

    [_tm1View addGestureRecognizer:uitgp];

    uitgp.numberOfTapsRequired = 1;

    _tm1View.userInteractionEnabled = YES;

    

    [self.d1ImageView addSubview:_tm1View];

 

// 点击事件响应内容

-(void)ddd{     

 

}

 

// 需要注意的一点是  必须是YES

_d1ImageView.userInteractionEnabled = YES;

 

posted @ 2016-04-12 10:45  悠扬007  阅读(167)  评论(0)    收藏  举报