Android程序開(kāi)發(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程序開(kāi)發(fā)之給背景圖加上移動(dòng)的手勢(shì)的全部?jī)?nèi)容,希望對(duì)大家有所幫助!
- Android游戲開(kāi)發(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)用開(kāi)發(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開(kāi)發(fā)基礎(chǔ)教程—SharedPreferences讀寫(xiě)
本文介紹SharedPreferences的讀與寫(xiě)的實(shí)現(xiàn)思路,感興趣的朋友可以了解下2013-01-01
Android System fastboot 介紹和使用教程
Fastboot是Android快速升級(jí)的一種方法,Fastboot的協(xié)議fastboot_protocol.txt在源碼目錄./bootable/bootloader/legacy下可以找到,本文給大家介紹Android System fastboot 介紹和使用教程,感興趣的朋友一起看看吧2024-01-01
Android開(kāi)發(fā)之EditText框輸入清理工具類(lèi)示例
這篇文章主要介紹了Android開(kāi)發(fā)之EditText框輸入清理工具類(lèi),涉及Android事件監(jiān)聽(tīng)及輸入框清理相關(guān)操作技巧,需要的朋友可以參考下2018-01-01
Android studio編寫(xiě)簡(jiǎn)單的手電筒APP
一個(gè)簡(jiǎn)單的APP控制的手電筒代碼,android studio編寫(xiě)一個(gè)手電筒app,調(diào)用手機(jī)的閃光等實(shí)現(xiàn)手電筒的功能,感興趣的小伙伴們可以參考一下2016-08-08
android實(shí)現(xiàn)百度地圖自定義彈出窗口功能
這篇文章主要介紹了android實(shí)現(xiàn)百度地圖自定義彈出窗口的功能,大家參考使用吧2013-11-11
Android實(shí)現(xiàn)個(gè)人資料頁(yè)面頭像背景模糊顯示包(狀態(tài)欄)
這篇文章主要介紹了Android實(shí)現(xiàn)個(gè)人資料頁(yè)面頭像背景模糊顯示包括狀態(tài)欄,非常不錯(cuò),具有參考借鑒價(jià)值,需要的朋友可以參考下2017-03-03
Android中使用ListView實(shí)現(xiàn)漂亮的表格效果
這篇文章主要介紹了Android中使用ListView實(shí)現(xiàn)漂亮的表格效果,本文用詳細(xì)的代碼實(shí)例創(chuàng)建了一個(gè)股票行情表格,需要的朋友可以參考下2014-10-10

