您的位置:首页 > 产品设计 > UI/UE

UIView添加点击事件

2016-08-24 18:24 197 查看
使用 UITapGestureRecognizer   ,创建一个 UITapGestureRecognizer  将它添加到view上即可

事例代码

   UIView *tapView=[[UIView alloc]initWithFrame:SCREEN_FRAME];
 
    UITapGestureRecognizer *tapGesturRecognizer=[[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(tapAction:)];
    [tapView addGestureRecognizer:tapGesturRecognizer];

   -(void)tapAction:(id)tap
  {
           NSLog(@"点击了tapView");
  }
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: