手机
当前位置:查字典教程网 >编程开发 >安卓软件开发 >Android程序开发之给背景图加上移动的手势
Android程序开发之给背景图加上移动的手势
摘要:一,工程图。二,效果图。三,代码。RootViewController.h#import@interfaceRootViewControll...

一,工程图。

Android程序开发之给背景图加上移动的手势1

二,效果图。

Android程序开发之给背景图加上移动的手势2

三,代码。

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. }

以上代码是有关Android程序开发之给背景图加上移动的手势的全部内容,希望对大家有所帮助!

【Android程序开发之给背景图加上移动的手势】相关文章:

android开发之横向滚动/竖向滚动的ListView(固定列头)

Android:多线程之进程与线程

Android开发之WebView组件的使用解析

Android开发之多个Activity间的交互

Eclipse开发Android程序如何在手机上运行

Android开发笔记之:在ImageView上绘制圆环的实现方法

Android开发笔记之:深入理解多线程AsyncTask

Android开发中比较耗时的一些操作小结

Android开发之软键盘用法实例分析

android开发之欢迎界面的小例子

精品推荐
分类导航