-
ios开发--旋转、移动、缩放手势实例代码
- - (void) addGestureRecognizerToView:(UIView *)view
- {
-
- UIRotationGestureRecognizer *rotationGestureRecognizer = [[UIRotationGestureRecognizer alloc] initWithTarget:self action:@selector(rotateView:)];
- [view addGestureRecognizer:rotationGestureRecognizer];
-
-
- UIPinchGestureRecognizer *pinchGestureRecognizer = [[UIPinchGestureRecognizer alloc] initWithTarget:self action:@selector(pinchView:)];
- [view addGestureRecognizer:pinchGestureRecognizer];
-
-
- UIPanGestureRecognizer *panGestureRecognizer = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(panView:)];
- [view addGestureRecognizer:panGestureRecognizer];
- }
-
- - (void) rotateView:(UIRotationGestureRecognizer *)rotationGestureRecognizer
- {
- UIView *view = rotationGestureRecognizer.view;
- if (rotationGestureRecognizer.state == UIGestureRecognizerStateBegan || rotationGestureRecognizer.state == UIGestureRecognizerStateChanged) {
- view.transform = CGAffineTransformRotate(view.transform, rotationGestureRecognizer.rotation);
- [rotationGestureRecognizer setRotation:0];
- }
- }
-
- - (void) pinchView:(UIPinchGestureRecognizer *)pinchGestureRecognizer
- {
- UIView *view = pinchGestureRecognizer.view;
- if (pinchGestureRecognizer.state == UIGestureRecognizerStateBegan || pinchGestureRecognizer.state == UIGestureRecognizerStateChanged) {
- view.transform = CGAffineTransformScale(view.transform, pinchGestureRecognizer.scale, pinchGestureRecognizer.scale);
- pinchGestureRecognizer.scale = 1;
- }
- }
-
- - (void) panView:(UIPanGestureRecognizer *)panGestureRecognizer
- {
- UIView *view = panGestureRecognizer.view;
- if (panGestureRecognizer.state == UIGestureRecognizerStateBegan || panGestureRecognizer.state == UIGestureRecognizerStateChanged) {
- CGPoint translation = [panGestureRecognizer translationInView:view.superview];
- [view setCenter:(CGPoint){view.center.x + translation.x, view.center.y + translation.y}];
- [panGestureRecognizer setTranslation:CGPointZero inView:view.superview];
- }
- }
-
相关阅读:
导出CSV乱码
php让一个数组按照另外一个数组的键名进行排序
电脑没有网
Android抓包方法(转)
封装curl的get和post请求
JavaScript动态加载CSS和JS文件
压缩视频之后网页上只有声音,没有图像
php BCMath高精度计算
非table结构数据导入excel
如何将页面上的数据导入excel中
-
原文地址:https://www.cnblogs.com/swallow37/p/3836362.html
Copyright © 2020-2023
润新知