Android程序開發(fā)之給背景圖加上移動的手勢
一,工程圖。
二,效果圖。
三,代碼。
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]; //移動的手勢 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(@"--移動的手勢-----"); } - (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; // Dispose of any resources that can be recreated. }
以上代碼是有關(guān)Android程序開發(fā)之給背景圖加上移動的手勢的全部內(nèi)容,希望對大家有所幫助!
相關(guān)文章
Android編程實現(xiàn)基于局域網(wǎng)udp廣播自動建立socket連接的方法
這篇文章主要介紹了Android編程實現(xiàn)基于局域網(wǎng)udp廣播自動建立socket連接的方法,涉及Android使用udp廣播實現(xiàn)socket通訊的相關(guān)技巧,具有一定參考借鑒價值,需要的朋友可以參考下2015-11-11Android實現(xiàn)獲取meta-data和build.gradle的值
這篇文章主要介紹了Android實現(xiàn)獲取meta-data和build.gradle的值,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧2020-03-03Android調(diào)用OpenCV2.4.10實現(xiàn)二維碼區(qū)域定位
這篇文章主要為大家詳細介紹了Android調(diào)用OpenCV 2.4.10實現(xiàn)二維碼區(qū)域定位,文中示例代碼介紹的非常詳細,具有一定的參考價值,感興趣的小伙伴們可以參考一下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編程實現(xiàn)popupwindow彈出后屏幕背景變成半透明效果
這篇文章主要介紹了Android編程實現(xiàn)popupwindow彈出后屏幕背景變成半透明效果,涉及Android設(shè)置getWindows透明度的方法,需要的朋友可以參考下2016-01-01Android selector狀態(tài)選擇器的使用詳解
這篇文章主要為大家詳細介紹了Android selector狀態(tài)選擇器的使用方法,具有一定的參考價值,感興趣的小伙伴們可以參考一下2018-09-09Android實現(xiàn)個人資料頁面頭像背景模糊顯示包(狀態(tài)欄)
這篇文章主要介紹了Android實現(xiàn)個人資料頁面頭像背景模糊顯示包括狀態(tài)欄,非常不錯,具有參考借鑒價值,需要的朋友可以參考下2017-03-03