给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];

 

posted @ 2015-01-30 10:44  Joker·venus  阅读(885)  评论(0编辑  收藏  举报