给uiview添加点击事件

时间:2015-01-30 14:38:12   收藏:0   阅读:145

前段时间遇到一个问题,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];

 

评论(0
© 2014 mamicode.com 版权所有 京ICP备13008772号-2  联系我们:gaon5@hotmail.com
迷上了代码!