Android程序開發(fā)之給背景圖加上移動的手勢
更新時間:2016年03月10日 10:12:47 作者:Livia.Chen
這篇文章主要介紹了Android程序開發(fā)之給背景圖加上移動的手勢 的相關(guā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
{
//紅色的背景圖
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開發(fā)基礎(chǔ)教程—SharedPreferences讀寫
本文介紹SharedPreferences的讀與寫的實現(xiàn)思路,感興趣的朋友可以了解下2013-01-01
Android System fastboot 介紹和使用教程
Fastboot是Android快速升級的一種方法,Fastboot的協(xié)議fastboot_protocol.txt在源碼目錄./bootable/bootloader/legacy下可以找到,本文給大家介紹Android System fastboot 介紹和使用教程,感興趣的朋友一起看看吧2024-01-01
Android開發(fā)之EditText框輸入清理工具類示例
這篇文章主要介紹了Android開發(fā)之EditText框輸入清理工具類,涉及Android事件監(jiān)聽及輸入框清理相關(guān)操作技巧,需要的朋友可以參考下2018-01-01
Android實現(xiàn)個人資料頁面頭像背景模糊顯示包(狀態(tài)欄)
這篇文章主要介紹了Android實現(xiàn)個人資料頁面頭像背景模糊顯示包括狀態(tài)欄,非常不錯,具有參考借鑒價值,需要的朋友可以參考下2017-03-03
Android中使用ListView實現(xiàn)漂亮的表格效果
這篇文章主要介紹了Android中使用ListView實現(xiàn)漂亮的表格效果,本文用詳細(xì)的代碼實例創(chuàng)建了一個股票行情表格,需要的朋友可以參考下2014-10-10

