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

iOS 手勢之左右滑動

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

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

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

1. 先創(chuàng)建一個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 = @"尼瑪?shù)? 你在往左邊跑啊...."
  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 = @"尼瑪?shù)? 你在往右邊跑啊...."
  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參數(shù)

2014-12-31 16:48:43

Touch touchevent多點觸摸

2019-04-16 09:47:42

iOS應用系統(tǒng)

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

物聯(lián)網智能建筑樓宇自控
點贊
收藏

51CTO技術棧公眾號

主站蜘蛛池模板: 亚洲入口| 亚洲一区二区在线 | 99精品视频一区二区三区 | 一区二区三区四区不卡 | 国产女人与拘做受免费视频 | 波多野结衣中文字幕一区二区三区 | 色一情一乱一伦一区二区三区 | 欧美不卡一区二区 | 国产精品极品美女在线观看免费 | 在线观看a视频 | 色综合久久伊人 | 国产精品福利网站 | av毛片| 日日摸夜夜添夜夜添精品视频 | 国产精品一区二区久久精品爱微奶 | 中日韩毛片| 欧美8一10sex性hd| 日韩视频二区 | 亚洲精品久久久久久一区二区 | 亚洲欧美日韩在线一区二区 | 精品一二区 | 日韩精品一区二区三区视频播放 | 中文字幕在线第二页 | 奇米av | 日韩视频三区 | 亚洲激情自拍偷拍 | 九九九久久国产免费 | 国产精品国产三级国产aⅴ浪潮 | 久久亚洲二区 | 日韩福利| 欧美午夜精品久久久久免费视 | 国产精品高潮呻吟久久 | 永久精品 | 狠狠草视频 | 亚洲第一av | 国产精品国产成人国产三级 | 久久国产视频网 | 精品国产综合 | 天天爱爱网 | 欧美区日韩区 | 精品美女 |