資源簡介
ios. oc 實現的,手指在屏幕上滑動獲得前一個矩形框. 可以自定義矩形位置.ios. oc 實現的,手指在屏幕上滑動獲得前一個矩形框. 可以自定義矩形位置.

代碼片段和文件信息
//
//??CLWOverLayView.m
//??CheLianWang
//
//??Created?by?馬建奎?on?2018/11/22.
//??Copyright???2018年?MaJiankui.?All?rights?reserved.
//
#import?“CLWOverLayView.h“
@interface?CLWOverLayView?()
{
????CGFloat?_selfHeight;
????CGFloat?_selfWidth;
????CGRect?_cropframe;
????
????BOOL?_topLineMove;
????BOOL?_leftLineMove;
????BOOL?_bottomLineMove;
????BOOL?_rightLineMove;
????
????CGPoint?_lastPoint;
????CGPoint?_endPoint;
????
????CGPoint?_topLeftPoint;
????CGPoint?_topRightPoint;
????CGPoint?_bottomLeftPoint;
????CGPoint?_bottomRightPoint;
????
????BOOL?_topLeftPointMove;
????BOOL?_topRightPointMove;
????BOOL?_bottomLeftPointMove;
????BOOL?_bottomRightPointMove;
}
@property?(nonatomic?strong)?UIView?*contentView;
@property?(nonatomic?strong)?CAShapelayer?*croplayer;
@end
@implementation?CLWOverLayView
-?(instancetype)initWithframe:(CGRect)frame?{
????if?(self?=?[super?initWithframe:frame])?{
????????
????????[self?addSubview:self.contentView];
????????[self?addSubview:self.messageLabel];
????????[self?addSubview:self.topLeftPointView];
????????[self?addSubview:self.topRightPointView];
????????[self?addSubview:self.bottomLeftPointView];
????????[self?addSubview:self.bottomRightPointView];
????????
????????[self?setDefaultData];
????}
????return?self;
}
-?(void)layoutSubviews?{
????[super?layoutSubviews];
}
#pragma?mark?-
-?(void)setDefaultData?{
????
????_topLeftPointMove?=?false;
????_topRightPointMove?=?false;
????_bottomLeftPointMove?=?false;
????_bottomRightPointMove?=?false;
????
????_selfWidth?=?self.width;
????_selfHeight?=?self.height;
????
????_topLeftPoint?=?CGPointMake(0.0?0.0);
????_topRightPoint?=?CGPointMake(0.0?0.0);
????_bottomRightPoint?=?CGPointMake(0.0?0.0);
????_bottomLeftPoint?=?CGPointMake(0.0?0.0);
????
????//設置裁剪框區域
????[self?restframeData];
}
//?刷新尺寸信息
-?(void)restframeData?{
????
????//?x?最小?y?最小.
????CGFloat?x?=?_topLeftPoint.x?????CGFloat?y?=?_topLeftPoint.y?????CGFloat?width?=?[self?getPintDistanceFromPoint:_topLeftPoint?toPoint:_topRightPoint];
????CGFloat?height?=?[self?getPintDistanceFromPoint:_topLeftPoint?toPoint:_bottomLeftPoint];
????
????//設置裁剪框尺寸
????self.cropSize?=?CGSizeMake(width?height);
????
????//設置裁剪框區域
????_cropframe?=?CGRectMake(xywidthheight);
????
????[self?transparentCutSquareArea];
}
//?矩形裁剪區域
-?(void)transparentCutSquareArea?{
????
????self.cropframe?=?_cropframe;
????
????//矩形裁剪區域
????UIBezierPath?*alphaPath?=?[UIBezierPath?bezierPathWithRect:CGRectMake(0?0?_selfWidth?_selfHeight)];
????UIBezierPath?*squarePath?=?[UIBezierPath?bezierPathWithRect:_cropframe];
????[alphaPath?appendPath:squarePath];
????CAShapelayer?*shapelayer?=?[CAShapelayer?layer];
????shapelayer.path?=?alphaPath.CGPath;
????shapelayer.fillRule?=?kCAFillRuleEvenOdd;
????self.contentView.layer.mask?=?shapelayer;
????
????//裁剪框
????UIBezierPath?*cropPath?=?[UIBezierPath?bezierPathWithRect:CGRectM
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????目錄???????????0??2018-12-22?15:06??overLayview\
?????文件?????????895??2018-12-22?15:00??overLayview\CLWOverLayView.h
?????目錄???????????0??2018-12-22?15:06??__MACOSX\
?????目錄???????????0??2018-12-22?15:06??__MACOSX\overLayview\
?????文件?????????333??2018-12-22?15:00??__MACOSX\overLayview\._CLWOverLayView.h
?????文件???????13058??2018-12-22?15:00??overLayview\CLWOverLayView.m
?????文件?????????333??2018-12-22?15:00??__MACOSX\overLayview\._CLWOverLayView.m
評論
共有 條評論