Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
O
Opple-iOS
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
张杰
Opple-iOS
Commits
af8e692b
Commit
af8e692b
authored
May 15, 2016
by
zhu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
no message
parent
02070814
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
55 additions
and
13 deletions
+55
-13
ImageCropperView.m
Lighting/Class/tools/ImageCropperView.m
+55
-13
No files found.
Lighting/Class/tools/ImageCropperView.m
View file @
af8e692b
...
@@ -44,29 +44,71 @@
...
@@ -44,29 +44,71 @@
self
.
backgroundColor
=
[
UIColor
clearColor
];
self
.
backgroundColor
=
[
UIColor
clearColor
];
[
self
setUserInteractionEnabled
:
YES
];
[
self
setUserInteractionEnabled
:
YES
];
[
self
setMultipleTouchEnabled
:
YES
];
[
self
setMultipleTouchEnabled
:
YES
];
// 旋转手势
// 旋转
UIRotationGestureRecognizer
*
rotationGestureRecognizer
=
[[
UIRotationGestureRecognizer
alloc
]
initWithTarget
:
self
action
:
@selector
(
rotateView
:
)];
UIRotationGestureRecognizer
*
rotateGes
=
[[
UIRotationGestureRecognizer
alloc
]
initWithTarget
:
self
action
:
@selector
(
rotateImage
:
)];
[
self
addGestureRecognizer
:
rotationGestureRecognizer
];
[
self
addGestureRecognizer
:
rotateGes
];
// 缩放手势
UIPinchGestureRecognizer
*
pinchGestureRecognizer
=
[[
UIPinchGestureRecognizer
alloc
]
initWithTarget
:
self
action
:
@selector
(
pinchView
:
)];
[
self
addGestureRecognizer
:
pinchGestureRecognizer
];
// 放大缩小
// 移动手势
UIPinchGestureRecognizer
*
scaleGes
=
[[
UIPinchGestureRecognizer
alloc
]
initWithTarget
:
self
action
:
@selector
(
scaleImage
:
)];
UIPanGestureRecognizer
*
panGestureRecognizer
=
[[
UIPanGestureRecognizer
alloc
]
initWithTarget
:
self
action
:
@selector
(
panView
:
)];
[
self
addGestureRecognizer
:
scaleGes
];
[
panGestureRecognizer
setMinimumNumberOfTouches
:
1
];
[
panGestureRecognizer
setMaximumNumberOfTouches
:
1
];
[
self
addGestureRecognizer
:
panGestureRecognizer
];
//// 旋转
// UIRotationGestureRecognizer *rotateGes = [[UIRotationGestureRecognizer alloc] initWithTarget:self action:@selector(rotateImage:)];
// [self addGestureRecognizer:rotateGes];
//
//// 放大缩小
// UIPinchGestureRecognizer *scaleGes = [[UIPinchGestureRecognizer alloc] initWithTarget:self action:@selector(scaleImage:)];
// [self addGestureRecognizer:scaleGes];
//
//
//// 移动
// UIPanGestureRecognizer *moveGes = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(moveImage:)];
// [moveGes setMinimumNumberOfTouches:1];
// [moveGes setMaximumNumberOfTouches:1];
// [self addGestureRecognizer:moveGes];
// 长按
// 长按
UILongPressGestureRecognizer
*
longPressGR
=
UILongPressGestureRecognizer
*
longPressGR
=
[[
UILongPressGestureRecognizer
alloc
]
initWithTarget
:
self
action
:
@selector
(
handleLongPress2
:
)];
[[
UILongPressGestureRecognizer
alloc
]
initWithTarget
:
self
action
:
@selector
(
handleLongPress2
:
)];
longPressGR
.
allowableMovement
=
NO
;
longPressGR
.
allowableMovement
=
NO
;
longPressGR
.
minimumPressDuration
=
0
.
5
;
longPressGR
.
minimumPressDuration
=
0
.
5
;
[
self
addGestureRecognizer
:
longPressGR
];
[
self
addGestureRecognizer
:
longPressGR
];
// 移动
UIPanGestureRecognizer
*
moveGes
=
[[
UIPanGestureRecognizer
alloc
]
initWithTarget
:
self
action
:
@selector
(
moveImage
:
)];
[
moveGes
setMinimumNumberOfTouches
:
1
];
[
moveGes
setMaximumNumberOfTouches
:
1
];
[
self
addGestureRecognizer
:
moveGes
];
}
}
// 处理旋转手势
-
(
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
];
}
}
float
_lastTransX
=
0
.
0
,
_lastTransY
=
0
.
0
;
float
_lastTransX
=
0
.
0
,
_lastTransY
=
0
.
0
;
-
(
void
)
moveImage
:(
UIPanGestureRecognizer
*
)
sender
-
(
void
)
moveImage
:(
UIPanGestureRecognizer
*
)
sender
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment