首页 > 代码库 > 给uiview添加点击事件

给uiview添加点击事件

前段时间遇到一个问题,navigation上的左侧返回按钮需要自定义,于是就给了一个view上去 代码如下

    UIView *leftitleView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 200, 54)];    [leftitleView addSubview:lab];    UITapGestureRecognizer *singleTap=[[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(cancel)];    [leftitleView addGestureRecognizer:singleTap];    self.navigationItem.leftBarButtonItem=[[UIBarButtonItem alloc]initWithCustomView:leftitleView];

 

给uiview添加点击事件