码迷,mamicode.com
首页 > 其他好文 > 详细

UIView单击手势的添加

时间:2014-11-15 17:05:33      阅读:265      评论:0      收藏:0      [点我收藏+]

标签:style   blog   http   io   color   ar   sp   div   on   

 

效果图:

 

bubuko.com,布布扣

 

代码:

- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    self.title=@"单击手势的添加";
    
    UIView *parentView=[[UIView alloc]initWithFrame:CGRectMake(50, 100, 200, 200)];
    parentView.backgroundColor=[UIColor redColor];
    [self.view addSubview:parentView];
    
    //单击的手势
    UITapGestureRecognizer *tapRecognize = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(handleTap:)];
    tapRecognize.numberOfTapsRequired = 1;
    tapRecognize.delegate = self;
    [tapRecognize setEnabled :YES];
    [tapRecognize delaysTouchesBegan];
    [tapRecognize cancelsTouchesInView];
    
    [self.view addGestureRecognizer:tapRecognize];

}
#pragma UIGestureRecognizer Handles
-(void) handleTap:(UITapGestureRecognizer *)recognizer
{
    NSLog(@"---单击手势-------");
}

 

UIView单击手势的添加

标签:style   blog   http   io   color   ar   sp   div   on   

原文地址:http://www.cnblogs.com/yang-guang-girl/p/4099517.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!