【移动应用开发技术】iOS中如何实现动态区域裁剪图片功能_第1页
【移动应用开发技术】iOS中如何实现动态区域裁剪图片功能_第2页
【移动应用开发技术】iOS中如何实现动态区域裁剪图片功能_第3页
【移动应用开发技术】iOS中如何实现动态区域裁剪图片功能_第4页
【移动应用开发技术】iOS中如何实现动态区域裁剪图片功能_第5页
已阅读5页,还剩25页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

【移动应用开发技术】iOS中如何实现动态区域裁剪图片功能

前言显示图片与裁剪区域支持移动和缩放图片支持手势改变裁剪区域显示图片与裁剪区域显示图片/upload/information/20200623/126/120610.jpg/upload/information/20200623/126/120611.jpg/upload/information/20200623/126/120612.jpg/upload/information/20200623/126/120614.jpg裁剪区域/upload/information/20200623/126/120616.jpg#import

<QuartzCore/QuartzCore.h>

@interface

YasicClipAreaLayer

:

CAShapeLayer

@property(assign,

nonatomic)

NSInteger

cropAreaLeft;

@property(assign,

nonatomic)

NSInteger

cropAreaTop;

@property(assign,

nonatomic)

NSInteger

cropAreaRight;

@property(assign,

nonatomic)

NSInteger

cropAreaBottom;

-

(void)setCropAreaLeft:(NSInteger)cropAreaLeft

CropAreaTop:(NSInteger)cropAreaTop

CropAreaRight:(NSInteger)cropAreaRight

CropAreaBottom:(NSInteger)cropAreaBottom;

@end

@implementation

YasicClipAreaLayer

-

(instancetype)init

{

self

=

[super

init];

if

(self)

{

_cropAreaLeft

=

50;

_cropAreaTop

=

50;

_cropAreaRight

=

SCREEN_WIDTH

-

self.cropAreaLeft;

_cropAreaBottom

=

400;

}

return

self;

}

-

(void)drawInContext:(CGContextRef)ctx

{

UIGraphicsPushContext(ctx);

CGContextSetStrokeColorWithColor(ctx,

[UIColor

whiteColor].CGColor);

CGContextSetLineWidth(ctx,

lineWidth);

CGContextMoveToPoint(ctx,

self.cropAreaLeft,

self.cropAreaTop);

CGContextAddLineToPoint(ctx,

self.cropAreaLeft,

self.cropAreaBottom);

CGContextSetShadow(ctx,

CGSizeMake(2,

0),

2.0);

CGContextStrokePath(ctx);

CGContextSetStrokeColorWithColor(ctx,

[UIColor

whiteColor].CGColor);

CGContextSetLineWidth(ctx,

lineWidth);

CGContextMoveToPoint(ctx,

self.cropAreaLeft,

self.cropAreaTop);

CGContextAddLineToPoint(ctx,

self.cropAreaRight,

self.cropAreaTop);

CGContextSetShadow(ctx,

CGSizeMake(0,

2),

2.0);

CGContextStrokePath(ctx);

CGContextSetStrokeColorWithColor(ctx,

[UIColor

whiteColor].CGColor);

CGContextSetLineWidth(ctx,

lineWidth);

CGContextMoveToPoint(ctx,

self.cropAreaRight,

self.cropAreaTop);

CGContextAddLineToPoint(ctx,

self.cropAreaRight,

self.cropAreaBottom);

CGContextSetShadow(ctx,

CGSizeMake(-2,

0),

2.0);

CGContextStrokePath(ctx);

CGContextSetStrokeColorWithColor(ctx,

[UIColor

whiteColor].CGColor);

CGContextSetLineWidth(ctx,

lineWidth);

CGContextMoveToPoint(ctx,

self.cropAreaLeft,

self.cropAreaBottom);

CGContextAddLineToPoint(ctx,

self.cropAreaRight,

self.cropAreaBottom);

CGContextSetShadow(ctx,

CGSizeMake(0,

-2),

2.0);

CGContextStrokePath(ctx);

UIGraphicsPopContext();

}

-

(void)setCropAreaLeft:(NSInteger)cropAreaLeft

{

_cropAreaLeft

=

cropAreaLeft;

[self

setNeedsDisplay];

}

-

(void)setCropAreaTop:(NSInteger)cropAreaTop

{

_cropAreaTop

=

cropAreaTop;

[self

setNeedsDisplay];

}

-

(void)setCropAreaRight:(NSInteger)cropAreaRight

{

_cropAreaRight

=

cropAreaRight;

[self

setNeedsDisplay];

}

-

(void)setCropAreaBottom:(NSInteger)cropAreaBottom

{

_cropAreaBottom

=

cropAreaBottom;

[self

setNeedsDisplay];

}

-

(void)setCropAreaLeft:(NSInteger)cropAreaLeft

CropAreaTop:(NSInteger)cropAreaTop

CropAreaRight:(NSInteger)cropAreaRight

CropAreaBottom:(NSInteger)cropAreaBottom

{

_cropAreaLeft

=

cropAreaLeft;

_cropAreaRight

=

cropAreaRight;

_cropAreaTop

=

cropAreaTop;

_cropAreaBottom

=

cropAreaBottom;

[self

setNeedsDisplay];

}

@end

self.cropView.layer.sublayers

=

nil;

YasicClipAreaLayer

*

layer

=

[[YasicClipAreaLayer

alloc]

init];

CGRect

cropframe

=

CGRectMake(self.cropAreaX,

self.cropAreaY,

self.cropAreaWidth,

self.cropAreaHeight);

UIBezierPath

*

path

=

[UIBezierPath

bezierPathWithRoundedRect:self.cropView.frame

cornerRadius:0];

UIBezierPath

*

cropPath

=

[UIBezierPath

bezierPathWithRect:cropframe];

[path

appendPath:cropPath];

layer.path

=

path.CGPath;

layer.fillRule

=

kCAFillRuleEvenOdd;

layer.fillColor

=

[[UIColor

blackColor]

CGColor];

layer.opacity

=

0.5;

layer.frame

=

self.cropView.bounds;

[layer

setCropAreaLeft:self.cropAreaX

CropAreaTop:self.cropAreaY

CropAreaRight:self.cropAreaX

+

self.cropAreaWidth

CropAreaBottom:self.cropAreaY

+

self.cropAreaHeight];

[self.cropView.layer

addSublayer:layer];

[self.view

bringSubviewToFront:self.cropView];/upload/information/20200623/126/120618.pngCGRect

cropframe

=

CGRectMake(self.cropAreaX,

self.cropAreaY,

self.cropAreaWidth,

self.cropAreaHeight);

UIBezierPath

*

path

=

[UIBezierPath

bezierPathWithRoundedRect:self.cropView.frame

cornerRadius:0];

UIBezierPath

*

cropPath

=

[UIBezierPath

bezierPathWithRect:cropframe];

[path

appendPath:cropPath];

layer.path

=

path.CGPath;

layer.fillRule

=

kCAFillRuleEvenOdd;

layer.fillColor

=

[[UIColor

blackColor]

CGColor];

layer.opacity

=

0.5;

layer.frame

=

self.cropView.bounds;/upload/information/20200623/126/120620.png/upload/information/20200623/126/120621.png

[layer

setCropAreaLeft:self.cropAreaX

CropAreaTop:self.cropAreaY

CropAreaRight:self.cropAreaX

+

self.cropAreaWidth

CropAreaBottom:self.cropAreaY

+

self.cropAreaHeight];

[self.cropView.layer

addSublayer:layer];

[self.view

bringSubviewToFront:self.cropView];合理放置图片/upload/information/20200623/126/120622.png

CGFloat

tempWidth

=

0.0;

CGFloat

tempHeight

=

0.0;

if

(self.targetImage.size.width/self.cropAreaWidth

<=

self.targetImage.size.height/self.cropAreaHeight)

{

tempWidth

=

self.cropAreaWidth;

tempHeight

=

(tempWidth/self.targetImage.size.width)

*

self.targetImage.size.height;

}

else

if

(self.targetImage.size.width/self.cropAreaWidth

>

self.targetImage.size.height/self.cropAreaHeight)

{

tempHeight

=

self.cropAreaHeight;

tempWidth

=

(tempHeight/self.targetImage.size.height)

*

self.targetImage.size.width;

}

[self.bigImageView

mas_updateConstraints:^(MASConstraintMaker

*make)

{

make.left.mas_equalTo(self.cropAreaX

-

(tempWidth

-

self.cropAreaWidth)/2);

make.top.mas_equalTo(self.cropAreaY

-

(tempHeight

-

self.cropAreaHeight)/2);

make.width.mas_equalTo(tempWidth);

make.height.mas_equalTo(tempHeight);

}];/upload/information/20200623/126/120623.jpg支持移动和缩放图片缩放功能self.originalFrame

=

CGRectMake(self.cropAreaX

-

(tempWidth

-

self.cropAreaWidth)/2,

self.cropAreaY

-

(tempHeight

-

self.cropAreaHeight)/2,

tempWidth,

tempHeight);

//

捏合手势

UIPinchGestureRecognizer

*pinGesture

=

[[UIPinchGestureRecognizer

alloc]

initWithTarget:self

action:@selector(handleCenterPinGesture:)];

[self.view

addGestureRecognizer:pinGesture];-(void)handleCenterPinGesture:(UIPinchGestureRecognizer

*)pinGesture

{

CGFloat

scaleRation

=

3;

UIView

*

view

=

self.bigImageView;

//

缩放开始与缩放中

if

(pinGesture.state

==

UIGestureRecognizerStateBegan

||

pinGesture.state

==

UIGestureRecognizerStateChanged)

{

//

移动缩放中心到手指中心

CGPoint

pinchCenter

=

[pinGesture

locationInView:view.superview];

CGFloat

distanceX

=

view.frame.origin.x

-

pinchCenter.x;

CGFloat

distanceY

=

view.frame.origin.y

-

pinchCenter.y;

CGFloat

scaledDistanceX

=

distanceX

*

pinGesture.scale;

CGFloat

scaledDistanceY

=

distanceY

*

pinGesture.scale;

CGRect

newFrame

=

CGRectMake(view.frame.origin.x

+

scaledDistanceX

-

distanceX,

view.frame.origin.y

+

scaledDistanceY

-

distanceY,

view.frame.size.width

*

pinGesture.scale,

view.frame.size.height

*

pinGesture.scale);

view.frame

=

newFrame;

pinGesture.scale

=

1;

}

//

缩放结束

if

(pinGesture.state

==

UIGestureRecognizerStateEnded)

{

CGFloat

ration

=

view.frame.size.width

/

self.originalFrame.size.width;

//

缩放过大

if

(ration

>

5)

{

CGRect

newFrame

=

CGRectMake(0,

0,

self.originalFrame.size.width

*

scaleRation,

self.originalFrame.size.height

*

scaleRation);

view.frame

=

newFrame;

}

//

缩放过小

if

(ration

<

0.25)

{

view.frame

=

self.originalFrame;

}

//

对图片进行位置修正

CGRect

resetPosition

=

CGRectMake(view.frame.origin.x,

view.frame.origin.y,

view.frame.size.width,

view.frame.size.height);

if

(resetPosition.origin.x

>=

self.cropAreaX)

{

resetPosition.origin.x

=

self.cropAreaX;

}

if

(resetPosition.origin.y

>=

self.cropAreaY)

{

resetPosition.origin.y

=

self.cropAreaY;

}

if

(resetPosition.size.width

+

resetPosition.origin.x

<

self.cropAreaX

+

self.cropAreaWidth)

{

CGFloat

movedLeftX

=

fabs(resetPosition.size.width

+

resetPosition.origin.x

-

(self.cropAreaX

+

self.cropAreaWidth));

resetPosition.origin.x

+=

movedLeftX;

}

if

(resetPosition.size.height

+

resetPosition.origin.y

<

self.cropAreaY

+

self.cropAreaHeight)

{

CGFloat

moveUpY

=

fabs(resetPosition.size.height

+

resetPosition.origin.y

-

(self.cropAreaY

+

self.cropAreaHeight));

resetPosition.origin.y

+=

moveUpY;

}

view.frame

=

resetPosition;

//

对图片缩放进行比例修正,防止过小

if

(self.cropAreaX

<

self.bigImageView.frame.origin.x

||

((self.cropAreaX

+

self.cropAreaWidth)

>

self.bigImageView.frame.origin.x

+

self.bigImageView.frame.size.width)

||

self.cropAreaY

<

self.bigImageView.frame.origin.y

||

((self.cropAreaY

+

self.cropAreaHeight)

>

self.bigImageView.frame.origin.y

+

self.bigImageView.frame.size.height))

{

view.frame

=

self.originalFrame;

}

}

}

if

(pinGesture.state

==

UIGestureRecognizerStateBegan

||

pinGesture.state

==

UIGestureRecognizerStateChanged)

{

//

移动缩放中心到手指中心

CGPoint

pinchCenter

=

[pinGesture

locationInView:view.superview];

CGFloat

distanceX

=

view.frame.origin.x

-

pinchCenter.x;

CGFloat

distanceY

=

view.frame.origin.y

-

pinchCenter.y;

CGFloat

scaledDistanceX

=

distanceX

*

pinGesture.scale;

CGFloat

scaledDistanceY

=

distanceY

*

pinGesture.scale;

CGRect

newFrame

=

CGRectMake(view.frame.origin.x

+

scaledDistanceX

-

distanceX,

view.frame.origin.y

+

scaledDistanceY

-

distanceY,

view.frame.size.width

*

pinGesture.scale,

view.frame.size.height

*

pinGesture.scale);

view.frame

=

newFrame;

pinGesture.scale

=

1;

}

CGRect

newFrame

=

CGRectMake(view.frame.origin.x

+

scaledDistanceX

-

distanceX,

view.frame.origin.y

+

scaledDistanceY

-

distanceY,

view.frame.size.width

*

pinGesture.scale,

view.frame.size.height

*

pinGesture.scale);CGFloat

ration

=

view.frame.size.width

/

self.originalFrame.size.width;

//

缩放过大

if

(ration

>

5)

{

CGRect

newFrame

=

CGRectMake(0,

0,

self.originalFrame.size.width

*

scaleRation,

self.originalFrame.size.height

*

scaleRation);

view.frame

=

newFrame;

}

//

缩放过小

if

(ration

<

0.25)

{

view.frame

=

self.originalFrame;

}//

对图片进行位置修正

CGRect

resetPosition

=

CGRectMake(view.frame.origin.x,

view.frame.origin.y,

view.frame.size.width,

view.frame.size.height);

if

(resetPosition.origin.x

>=

self.cropAreaX)

{

resetPosition.origin.x

=

self.cropAreaX;

}

if

(resetPosition.origin.y

>=

self.cropAreaY)

{

resetPosition.origin.y

=

self.cropAreaY;

}

if

(resetPosition.size.width

+

resetPosition.origin.x

<

self.cropAreaX

+

self.cropAreaWidth)

{

CGFloat

movedLeftX

=

fabs(resetPosition.size.width

+

resetPosition.origin.x

-

(self.cropAreaX

+

self.cropAreaWidth));

resetPosition.origin.x

+=

movedLeftX;

}

if

(resetPosition.size.height

+

resetPosition.origin.y

<

self.cropAreaY

+

self.cropAreaHeight)

{

CGFloat

moveUpY

=

fabs(resetPosition.size.height

+

resetPosition.origin.y

-

(self.cropAreaY

+

self.cropAreaHeight));

resetPosition.origin.y

+=

moveUpY;

}

view.frame

=

resetPosition;/upload/information/20200623/126/120624.png

//

对图片缩放进行比例修正,防止过小

if

(self.cropAreaX

<

self.bigImageView.frame.origin.x

||

((self.cropAreaX

+

self.cropAreaWidth)

>

self.bigImageView.frame.origin.x

+

self.bigImageView.frame.size.width)

||

self.cropAreaY

<

self.bigImageView.frame.origin.y

||

((self.cropAreaY

+

self.cropAreaHeight)

>

self.bigImageView.frame.origin.y

+

self.bigImageView.frame.size.height))

{

view.frame

=

self.originalFrame;

}移动功能

CGPoint

translation

=

[panGesture

translationInView:view.superview];

[view

setCenter:CGPointMake(view.center.x

+

translation.x,

view.center.y

+

translation.y)];

[panGesture

setTranslation:CGPointZero

inView:view.superview];

CGRect

currentFrame

=

view.frame;

if

(currentFrame.origin.x

>=

self.cropAreaX)

{

currentFrame.origin.x

=

self.cropAreaX;

}

if

(currentFrame.origin.y

>=

self.cropAreaY)

{

currentFrame.origin.y

=

self.cropAreaY;

}

if

(currentFrame.size.width

+

currentFrame.origin.x

<

self.cropAreaX

+

self.cropAreaWidth)

{

CGFloat

movedLeftX

=

fabs(currentFrame.size.width

+

currentFrame.origin.x

-

(self.cropAreaX

+

self.cropAreaWidth));

currentFrame.origin.x

+=

movedLeftX;

}

if

(currentFrame.size.height

+

currentFrame.origin.y

<

self.cropAreaY

+

self.cropAreaHeight)

{

CGFloat

moveUpY

=

fabs(currentFrame.size.height

+

currentFrame.origin.y

-

(self.cropAreaY

+

self.cropAreaHeight));

currentFrame.origin.y

+=

moveUpY;

}

[UIView

animateWithDuration:0.3

animations:^{

[view

setFrame:currentFrame];

}];支持手势改变裁剪区域typedef

NS_ENUM(NSInteger,

ACTIVEGESTUREVIEW)

{

CROPVIEWLEFT,

CROPVIEWRIGHT,

CROPVIEWTOP,

CROPVIEWBOTTOM,

BIGIMAGEVIEW

};@property(assign,

nonatomic)

ACTIVEGESTUREVIEW

activeGestureView;@interface

YasicPanGestureRecognizer

:

UIPanGestureRecognizer

@property(assign,

nonatomic)

CGPoint

beginPoint;

@property(assign,

nonatomic)

CGPoint

movePoint;

-(instancetype)initWithTarget:(id)target

action:(SEL)action

inview:(UIView*)view;

@end

@interface

YasicPanGestureRecognizer()

@property(strong,

nonatomic)

UIView

*targetView;

@end

@implementation

YasicPanGestureRecognizer

-(instancetype)initWithTarget:(id)target

action:(SEL)action

inview:(UIView*)view{

self

=

[super

initWithTarget:target

action:action];

if(self)

{

self.targetView

=

view;

}

return

self;

}

-

(void)touchesBegan:(NSSet

*)touches

withEvent:(UIEvent*)event{

[super

touchesBegan:touches

withEvent:event];

UITouch

*touch

=

[touches

anyObject];

self.beginPoint

=

[touch

locationInView:self.targetView];

}

-

(void)touchesMoved:(NSSet<UITouch

*>

*)touches

withEvent:(UIEvent

*)event

{

[super

touchesMoved:touches

withEvent:event];

UITouch

*touch

=

[touches

anyObject];

self.movePoint

=

[touch

locationInView:self.targetView];

}

@end

//

拖动手势

YasicPanGestureRecognizer

*panGesture

=

[[YasicPanGestureRecognizer

alloc]

initWithTarget:self

action:@selector(handleDynamicPanGesture:)

inview:self.cropView];

[self.cropView

addGestureRecognizer:panGesture];手势开始时//

开始滑动时判断滑动对象是

ImageView

还是

Layer

上的

Line

if

(panGesture.state

==

UIGestureRecognizerStateBegan)

{

if

(beginPoint.x

>=

self.cropAreaX

-

judgeWidth

&&

beginPoint.x

<=

self.cropAreaX

+

judgeWidth

&&

beginPoint.y

>=

self.cropAreaY

&&

beginPoint.y

<=

self.cropAreaY

+

self.cropAreaHeight

&&

self.cropAreaWidth

>=

50)

{

self.activeGestureView

=

CROPVIEWLEFT;

}

else

if

(beginPoint.x

>=

self.cropAreaX

+

self.cropAreaWidth

-

judgeWidth

&&

beginPoint.x

<=

self.cropAreaX

+

self.cropAreaWidth

+

judgeWidth

&&

beginPoint.y

>=

self.cropAreaY

&&

beginPoint.y

<=

self.cropAreaY

+

self.cropAreaHeight

&&

self.cropAreaWidth

>=

50)

{

self.activeGestureView

=

CROPVIEWRIGHT;

}

else

if

(beginPoint.y

>=

self.cropAreaY

-

judgeWidth

&&

beginPoint.y

<=

self.cropAreaY

+

judgeWidth

&&

beginPoint.x

>=

self.cropAreaX

&&

beginPoint.x

<=

self.cropAreaX

+

self.cropAreaWidth

&&

self.cropAreaHeight

>=

50)

{

self.activeGestureView

=

CROPVIEWTOP;

}

else

if

(beginPoint.y

>=

self.cropAreaY

+

self.cropAreaHeight

-

judgeWidth

&&

beginPoint.y

<=

self.cropAreaY

+

self.cropAreaHeight

+

judgeWidth

&&

beginPoint.x

>=

self.cropAreaX

&&

beginPoint.x

<=

self.cropAreaX

+

self.cropAreaWidth

&&

self.cropAreaHeight

>=

50)

{

self.activeGestureView

=

CROPVIEWBOTTOM;

}

else

{

self.activeGestureView

=

BIGIMAGEVIEW;

[view

setCenter:CGPointMake(view.center.x

+

translation.x,

view.center.y

+

translation.y)];

[panGesture

setTranslation:CGPointZero

inView:view.superview];

}

}手势进行时//

滑动过程中进行位置改变

if

(panGesture.state

==

UIGestureRecognizerStateChanged)

{

CGFloat

diff

=

0;

switch

(self.activeGestureView)

{

case

CROPVIEWLEFT:

{

diff

=

movePoint.x

-

self.cropAreaX;

if

(diff

>=

0

&&

self.cropAreaWidth

>

50)

{

self.cropAreaWidth

-=

diff;

self.cropAreaX

+=

diff;

}

else

if

(diff

<

0

&&

self.cropAreaX

>

self.bigImageView.frame.origin.x

&&

self.cropAreaX

>=

15)

{

self.cropAreaWidth

-=

diff;

self.cropAreaX

+=

diff;

}

[self

setUpCropLayer];

break;

}

case

CROPVIEWRIGHT:

{

diff

=

movePoint.x

-

self.cropAreaX

-

self.cropAreaWidth;

if

(diff

>=

0

&&

(self.cropAreaX

+

self.cropAreaWidth)

<

MIN(self.bigImageView.frame.origin.x

+

self.bigImageView.frame.size.width,

self.cropView.frame.origin.x

+

self.cropView.frame.size.width

-

15)){

self.cropAreaWidth

+=

diff;

}

else

if

(diff

<

0

&&

self.cropAreaWidth

>=

50)

{

self.cropAreaWidth

+=

diff;

}

[self

setUpCropLayer];

break;

}

case

CROPVIEWTOP:

{

diff

=

movePoint.y

-

self.cropAreaY;

if

(diff

>=

0

&&

self.cropAreaHeight

>

50)

{

self.cropAreaHeight

-=

diff;

self.cropAreaY

+=

diff;

}

else

if

(diff

<

0

&&

self.cropAreaY

>

self.bigImageView.frame.origin.y

&&

self.cropAreaY

>=

15)

{

self.cropAreaHeight

-=

diff;

self.cropAreaY

+=

diff;

}

[self

setUpCropLayer];

break;

}

case

CROPVIEWBOTTOM:

{

diff

=

movePoint.y

-

self.cropAreaY

-

self.cropAreaHeight;

if

(diff

>=

0

&&

(self.cropAreaY

+

self.cropAreaHeight)

<

MIN(self.bigImageView.frame.origin.y

+

self.bigImageView.frame.size.height,

self.cropView.frame.origin.y

+

self.cropView.frame.size.height

-

15)){

self.cropAreaHeight

+=

diff;

}

else

if

(diff

<

0

&&

self.cropAreaHeight

>=

50)

{

self.cropAreaHeight

+=

diff;

}

[self

setUpCropLayer];

break;

}

case

BIGIMAGEVIEW:

{

[view

setCenter:CGPointMake(view.center.x

+

translation.x,

view.center.y

+

translation.y)];

[panGesture

setTranslation:CGPointZero

inView:view.superview];

break;

}

default:

break;

}

}手势结束时

//

滑动结束后进行位置修正

if

(panGesture.state

==

UIGestureRecognizerStateEnded)

{

switch

(self.activeGestureView)

{

case

CROPVIEWLEFT:

{

if

(self.cropAreaWidth

<

50)

{

self.cropAreaX

-=

50

-

self.cropAreaWidth;

self.cropAreaWidth

=

50;

}

if

(self.cropAreaX

<

MAX(self.bigImageView.frame.origin.x,

15))

{

CGFloat

temp

=

self.cropAreaX

+

self.cropAreaWidth;

self.cropAreaX

=

MAX(self.bigImageView.frame.origin.x,

15);

self.cropAreaWidth

=

temp

-

self.cropAreaX;

}

[self

setUpCropLayer];

break;

}

case

CROPVIEWRIGHT:

{

if

(self.cropAreaWidth

<

50)

{

self.cropAreaWidth

=

50;

}

if

(self.cropAreaX

+

self.cropAreaWidth

>

MIN(self.bigImageView.frame.origin.x

+

self.bigImageView.frame.size.width,

self.cropView.frame.origin.x

+

self.cropView.frame.size.width

-

15))

{

self.cropAreaWidth

=

MIN(self.bigImageView.frame.origin.x

+

self.bigImageView.frame.size.width,

self.cropView.frame.origin.x

+

self.cropView.frame.size.width

-

15)

-

self.cropAreaX;

}

[self

setUpCropLayer];

break;

}

case

CROPVIEWTOP:

{

if

(self.cropAreaHeight

<

50)

{

self.cropAreaY

-=

50

-

self.cropAreaHeight;

self.cropAreaHeight

=

50;

}

if

(self.cropAreaY

<

MAX(self.bigImageView.frame.origin.y,

15))

{

CGFloat

temp

=

self.cropAreaY

+

self.cropAreaHeight;

self.cropAreaY

=

MAX(self.bigImageView.frame.origin.y,

15);

self.cropAreaHeight

=

temp

-

self.cropAreaY;

}

[self

setUpCropLayer];

break;

}

case

CROPVIEWBOTTOM:

{

if

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论