星空网 > 软件开发 > 操作系统

【代码笔记】给背景图加上移动的手势

一,工程图。

【代码笔记】给背景图加上移动的手势images/loading.gif' data-original="http://images2015.cnblogs.com/blog/337518/201510/337518-20151019115026474-214217871.jpg" width="218" height="400" />

二,效果图。

【代码笔记】给背景图加上移动的手势

三,代码。

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.}
【代码笔记】给背景图加上移动的手势

 




原标题:【代码笔记】给背景图加上移动的手势

关键词:

*特别声明:以上内容来自于网络收集,著作权属原作者所有,如有侵权,请联系我们: admin#shaoqun.com (#换成@)。

费用澳大利亚海运:https://www.goluckyvip.com/tag/31411.html
费用海运埃及:https://www.goluckyvip.com/tag/31412.html
费用南安普顿海运:https://www.goluckyvip.com/tag/31413.html
分叉智能:https://www.goluckyvip.com/tag/31414.html
分类审核 Categories Requiring Approval :https://www.goluckyvip.com/tag/31415.html
分类限制:https://www.goluckyvip.com/tag/31416.html
温州旧货市场有玻璃柜卖吗?:https://www.vstour.cn/a/411246.html
如何用摄影作品表现“芳草鲜美,落英缤纷”的:https://www.vstour.cn/a/411247.html
相关文章
我的浏览记录
最新相关资讯
海外公司注册 | 跨境电商服务平台 | 深圳旅行社 | 东南亚物流