成人免费xxxxx在线视频软件_久久精品久久久_亚洲国产精品久久久_天天色天天色_亚洲人成一区_欧美一级欧美三级在线观看

iOS 手勢之左右滑動

移動開發 iOS
本文作者為各位網友朋友們列出了一個iOS開發中左右滑動手勢的應用例子代碼,代碼很實用簡練,可以供各位網友參考學習之用。

今天想找些關于ios手勢的資料, 結果看了幾個都跑不起來, 后來東找找, 西找找終于可以弄了個跑起來的例子.......

下面例子主要做個左右滑動手勢.

1. 先創建一個SingleView的項目.

2. 然后在主界面上放一個Label, 主要用于測試滑動是否起作用.

3. 給label增加一個Outlet. 取名為 "swipeLabel"

4. 在"ViewController.h"中增加兩個手勢property.

  1. @property (nonatomic, strong) UISwipeGestureRecognizer *leftSwipeGestureRecognizer; 
  2. @property (nonatomic, strong) UISwipeGestureRecognizer *rightSwipeGestureRecognizer; 

并synthesize到"ViewController.m"文件中.

5.在"ViewController.m"文件中的"ViewDidLoad"方法中增加如下代碼:

  1. self.leftSwipeGestureRecognizer = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(handleSwipes:)];  
  2.         self.rightSwipeGestureRecognizer = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(handleSwipes:)];  
  3.         self.leftSwipeGestureRecognizer.direction = UISwipeGestureRecognizerDirectionLeft;  
  4.         self.rightSwipeGestureRecognizer.direction = UISwipeGestureRecognizerDirectionRight;  
  5.         [self.view addGestureRecognizer:self.leftSwipeGestureRecognizer];  
  6.         [self.view addGestureRecognizer:self.rightSwipeGestureRecognizer];  

6.并在"ViewController.m"中增加如下方法;

  1. - (void)handleSwipes:(UISwipeGestureRecognizer *)sender 
  2.     { 
  3.         if (sender.direction == UISwipeGestureRecognizerDirectionLeft) { 
  4.             CGPoint labelPosition = CGPointMake(self.swipeLabel.frame.origin.x - 100.0, self.swipeLabel.frame.origin.y); 
  5.             self.swipeLabel.frame = CGRectMake( labelPosition.x , labelPosition.y , self.swipeLabel.frame.size.width, self.swipeLabel.frame.size.height); 
  6.             self.swipeLabel.text = @"尼瑪的, 你在往左邊跑啊...."
  7.         } 
  8.         if (sender.direction == UISwipeGestureRecognizerDirectionRight) { 
  9.             CGPoint labelPosition = CGPointMake(self.swipeLabel.frame.origin.x + 100.0, self.swipeLabel.frame.origin.y); 
  10.             self.swipeLabel.frame = CGRectMake( labelPosition.x , labelPosition.y , self.swipeLabel.frame.size.width, self.swipeLabel.frame.size.height); 
  11.             self.swipeLabel.text = @"尼瑪的, 你在往右邊跑啊...."
  12.         } 
  13.     } 

7. 保存, 編譯, 運行....

責任編輯:閆佳明 來源: oschina
相關推薦

2015-02-28 15:55:32

手勢gesture過渡

2010-01-28 14:57:36

Android滑動手勢

2015-02-12 13:08:42

左右滑動PagerAdapte分頁

2021-05-29 20:47:00

微軟Windows 10Windows

2011-06-28 09:53:43

iPhone諾基亞N9

2012-12-24 08:54:47

iOSUnity3D

2014-10-09 10:42:48

iOS手勢識別

2017-10-10 15:14:23

BUGiOS 11蘋果

2015-07-22 10:34:59

手勢密碼源碼

2013-09-23 09:54:28

2024-06-21 08:27:21

ViewViewGroup參數

2014-12-31 16:48:43

Touch touchevent多點觸摸

2019-04-16 09:47:42

iOS應用系統

2020-04-24 16:08:12

Android 11新版本功能

2015-01-22 16:04:06

iPhone

2011-03-28 14:04:10

SQL左連接右連接

2013-05-14 11:18:24

AIR AndroidSwipe手勢

2013-07-18 18:14:26

UITableViewiOS長按手勢UILongPress

2021-05-20 09:00:27

SwiftUI Swift TapGesture

2022-05-17 12:25:59

物聯網智能建筑樓宇自控
點贊
收藏

51CTO技術棧公眾號

主站蜘蛛池模板: 日韩欧美在线不卡 | 艹逼网 | 国产亚洲网站 | 国产精品永久免费观看 | 国产精品久久久久久久免费观看 | 伦理午夜电影免费观看 | 久久草在线视频 | 成年免费大片黄在线观看一级 | 日本一区二区三区精品视频 | 欧美五月婷婷 | 插插插干干干 | 精品亚洲一区二区 | 国产精品不卡一区 | 日本精品视频在线观看 | 国产91久久精品一区二区 | 亚洲在线免费观看 | 国产欧美一区二区三区免费 | 97精品国产97久久久久久免费 | 美女一级毛片 | 成人av影院| 色一阁 | 成人在线观看网址 | 日韩视频中文字幕 | 麻豆av网站| 一级毛片免费完整视频 | 美女在线一区二区 | aaaaaa大片免费看最大的 | 亚洲午夜精品 | 亚洲色图综合 | 午夜噜噜噜 | 国产精品18久久久久久白浆动漫 | 久久久黑人 | 亚洲视频一区在线 | 日韩有码一区二区三区 | 天天色天天射天天干 | 日韩精品免费播放 | 在线免费视频一区 | 国产午夜三级一区二区三 | 国产综合久久久久久鬼色 | 国产精品1区2区3区 一区中文字幕 | 一级做a爰片久久毛片 |