Android程序開發(fā)之給背景圖加上移動(dòng)的手勢(shì)
一,工程圖。
二,效果圖。
三,代碼。
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 { //紅色的背景圖 UIView *parentView=[[UIView alloc]initWithFrame:CGRectMake(50, 100, 200, 200)]; parentView.backgroundColor=[UIColor redColor]; [self.view addSubview:parentView]; [parentView setUserInteractionEnabled:YES]; //移動(dòng)的手勢(shì) UIPanGestureRecognizer *panRcognize=[[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(handlePan:)]; panRcognize.delegate=self; [panRcognize setEnabled:YES]; [panRcognize delaysTouchesEnded]; [panRcognize cancelsTouchesInView]; [parentView addGestureRecognizer:panRcognize]; } #pragma UIGestureRecognizer Handles - (void)handlePan:(UIPanGestureRecognizer *)recognizer { NSLog(@"--移動(dòng)的手勢(shì)-----"); } - (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; // Dispose of any resources that can be recreated. }
以上代碼是有關(guān)Android程序開發(fā)之給背景圖加上移動(dòng)的手勢(shì)的全部?jī)?nèi)容,希望對(duì)大家有所幫助!
- Android游戲開發(fā):實(shí)現(xiàn)手勢(shì)操作切換圖片的實(shí)例
- Android觸摸及手勢(shì)操作GestureDetector
- Android手勢(shì)操作示例(上/下/左/右的判斷)
- Android手勢(shì)密碼的實(shí)現(xiàn)
- 超實(shí)用的Android手勢(shì)鎖制作實(shí)例教程
- Android應(yīng)用中實(shí)現(xiàn)手勢(shì)控制圖片縮放的完全攻略
- Android應(yīng)用開發(fā)中觸摸屏手勢(shì)識(shí)別的實(shí)現(xiàn)方法解析
- Android實(shí)現(xiàn)手勢(shì)滑動(dòng)多點(diǎn)觸摸縮放平移圖片效果(二)
- Android實(shí)現(xiàn)手勢(shì)滑動(dòng)多點(diǎn)觸摸縮放平移圖片效果
- Android 手勢(shì)操作編程詳解
相關(guān)文章
Android編程實(shí)現(xiàn)基于局域網(wǎng)udp廣播自動(dòng)建立socket連接的方法
這篇文章主要介紹了Android編程實(shí)現(xiàn)基于局域網(wǎng)udp廣播自動(dòng)建立socket連接的方法,涉及Android使用udp廣播實(shí)現(xiàn)socket通訊的相關(guān)技巧,具有一定參考借鑒價(jià)值,需要的朋友可以參考下2015-11-11Android實(shí)現(xiàn)獲取meta-data和build.gradle的值
這篇文章主要介紹了Android實(shí)現(xiàn)獲取meta-data和build.gradle的值,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過來看看吧2020-03-03Android調(diào)用OpenCV2.4.10實(shí)現(xiàn)二維碼區(qū)域定位
這篇文章主要為大家詳細(xì)介紹了Android調(diào)用OpenCV 2.4.10實(shí)現(xiàn)二維碼區(qū)域定位,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2018-03-03Android數(shù)據(jù)庫SD卡創(chuàng)建和圖片存取操作
這篇文章主要介紹了Android數(shù)據(jù)庫SD卡創(chuàng)建和圖片存取操作的相關(guān)資料,需要的朋友可以參考下2017-04-04Android 設(shè)置應(yīng)用全屏的兩種解決方法
本篇文章小編為大家介紹,Android 設(shè)置應(yīng)用全屏的兩種解決方法。需要的朋友參考下2013-04-04Android編程實(shí)現(xiàn)popupwindow彈出后屏幕背景變成半透明效果
這篇文章主要介紹了Android編程實(shí)現(xiàn)popupwindow彈出后屏幕背景變成半透明效果,涉及Android設(shè)置getWindows透明度的方法,需要的朋友可以參考下2016-01-01Android selector狀態(tài)選擇器的使用詳解
這篇文章主要為大家詳細(xì)介紹了Android selector狀態(tài)選擇器的使用方法,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2018-09-09Android開發(fā)之底圖局部加載移動(dòng)的方法示例
這篇文章主要介紹了Android開發(fā)之底圖局部加載移動(dòng)的方法,涉及Android針對(duì)圖片與屏幕屬性的讀取、計(jì)算、設(shè)置等相關(guān)操作技巧,需要的朋友可以參考下2017-08-08Android實(shí)現(xiàn)個(gè)人資料頁面頭像背景模糊顯示包(狀態(tài)欄)
這篇文章主要介紹了Android實(shí)現(xiàn)個(gè)人資料頁面頭像背景模糊顯示包括狀態(tài)欄,非常不錯(cuò),具有參考借鑒價(jià)值,需要的朋友可以參考下2017-03-03