Android   发布时间:2022-04-28  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了Android程序开发之给背景图加上移动的手势大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。

一,工程图。

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


二,效果图。

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


三,代码

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 @R_874_5550@es that can be recreated.
}

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

大佬总结

以上是大佬教程为你收集整理的Android程序开发之给背景图加上移动的手势全部内容,希望文章能够帮你解决Android程序开发之给背景图加上移动的手势所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。