欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

IOS 單擊手勢(shì)的添加實(shí)現(xiàn)代碼

 更新時(shí)間:2017年05月16日 11:13:44   作者:小弦事務(wù)所  
這篇文章主要介紹了IOS 單擊手勢(shì)的添加實(shí)現(xiàn)代碼的相關(guān)資料,需要的朋友可以參考下

IOS 單擊手勢(shì)的添加實(shí)現(xiàn)代碼

一,效果圖。

二,工程圖。

三,代碼。

RootViewController.h

#import <UIKit/UIKit.h>

@interface RootViewController : UIViewController
<UIGestureRecognizerDelegate>

@end

 RootViewController.m

#import "RootViewController.h"

@interface RootViewController ()

@end

@implementation RootViewController

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
  self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
  if (self) {
    // Custom initialization
  }
  return self;
}

- (void)viewDidLoad
{
  [super viewDidLoad];
  // Do any additional setup after loading the view.
  
  //添加背景
  [self addView];
}
#pragma -mark -functions
//添加背景
-(void)addView
{
  self.title=@"單擊手勢(shì)的添加";
  
  UIView *parentView=[[UIView alloc]initWithFrame:CGRectMake(50, 100, 200, 200)];
  parentView.backgroundColor=[UIColor redColor];
  [self.view addSubview:parentView];
  
  //單擊的手勢(shì)
  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(@"---單擊手勢(shì)-------");
}
- (void)didReceiveMemoryWarning
{
  [super didReceiveMemoryWarning];
  // Dispose of any resources that can be recreated.
}

感謝閱讀,希望能幫助到大家,謝謝大家對(duì)本站的支持!

相關(guān)文章

最新評(píng)論