源码网商城,靠谱的源码在线交易网站 我的订单 购物车 帮助

源码网商城

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

  • 时间:2020-04-07 02:01 编辑: 来源: 阅读:
  • 扫一扫,手机访问
摘要:Android程序开发之给背景图加上移动的手势
一,工程图。 [img]http://img.1sucai.cn/uploads/article/2018010710/20180107100127_0_71160.jpg[/img] 二,效果图。 [img]http://img.1sucai.cn/uploads/article/2018010710/20180107100127_1_91341.jpg[/img] 三,代码。 [b]RootViewController.h[/b]
#import <UIKit/UIKit.h>
@interface RootViewController : UIViewController
<UIGestureRecognizerDelegate>
@end 
[b]RootViewController.m[/b]
#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程序开发之给背景图加上移动的手势的全部内容,希望对大家有所帮助!
  • 全部评论(0)
联系客服
客服电话:
400-000-3129
微信版

扫一扫进微信版
返回顶部