mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-08-16 18:40:05 +00:00
+ Minimum Arrow Length.
This commit is contained in:
parent
2207f107e4
commit
a2d850b5c3
@ -44,30 +44,50 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
- (void)buildShape {
|
- (void)buildShape {
|
||||||
CGFloat topHeight = MAX(self.frame.size.width / 3.0f,10);
|
CGFloat baseWidth = MAX(self.frame.size.width, self.frame.size.height);
|
||||||
|
CGFloat topHeight = MAX(baseWidth / 3.0f,10);
|
||||||
|
|
||||||
|
|
||||||
CGFloat lineWidth = MAX(self.frame.size.width / 10.0f,3);
|
CGFloat lineWidth = MAX(baseWidth / 10.0f,3);
|
||||||
CGFloat startX, startY, endX, endY;
|
CGFloat startX, startY, endX, endY;
|
||||||
|
|
||||||
|
CGRect boundRect = CGRectInset(self.bounds, 0, 0);
|
||||||
|
CGFloat arrowLength= sqrt(pow(CGRectGetWidth(boundRect), 2) + pow(CGRectGetHeight(boundRect), 2));
|
||||||
|
if (arrowLength < 30){
|
||||||
|
|
||||||
|
CGFloat factor = 30.f/arrowLength;
|
||||||
|
|
||||||
|
boundRect = CGRectApplyAffineTransform(boundRect, CGAffineTransformMakeScale(factor,factor));
|
||||||
|
}
|
||||||
|
|
||||||
if ( self.movedDelta.width < 0){
|
if ( self.movedDelta.width < 0){
|
||||||
startX = CGRectGetMinX(self.bounds);
|
startX = CGRectGetMinX(boundRect);
|
||||||
endX = CGRectGetMaxX(self.bounds);
|
endX = CGRectGetMaxX(boundRect);
|
||||||
} else {
|
} else {
|
||||||
startX = CGRectGetMaxX(self.bounds);
|
startX = CGRectGetMaxX(boundRect);
|
||||||
endX = CGRectGetMinX(self.bounds);
|
endX = CGRectGetMinX(boundRect);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( self.movedDelta.height < 0){
|
if ( self.movedDelta.height < 0){
|
||||||
startY = CGRectGetMinY(self.bounds);
|
startY = CGRectGetMinY(boundRect);
|
||||||
endY = CGRectGetMaxY(self.bounds);
|
endY = CGRectGetMaxY(boundRect);
|
||||||
} else {
|
} else {
|
||||||
startY = CGRectGetMaxY(self.bounds);
|
startY = CGRectGetMaxY(boundRect);
|
||||||
endY = CGRectGetMinY(self.bounds);
|
endY = CGRectGetMinY(boundRect);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if (abs(CGRectGetWidth(boundRect)) < 30 || abs(CGRectGetHeight(boundRect)) < 30){
|
||||||
|
CGFloat smallerOne = MIN(abs(CGRectGetHeight(boundRect)), abs(CGRectGetWidth(boundRect)));
|
||||||
|
|
||||||
UIBezierPath *path = [self bezierPathWithArrowFromPoint:CGPointMake(endX,endY) toPoint:CGPointMake(startX,startY) tailWidth:lineWidth headWidth:topHeight headLength:topHeight];
|
CGFloat factor = smallerOne/30.f;
|
||||||
|
|
||||||
|
CGRectApplyAffineTransform(boundRect, CGAffineTransformMakeScale(factor,factor));
|
||||||
|
}
|
||||||
|
|
||||||
|
UIBezierPath *path = [self bezierPathWithArrowFromPoint:CGPointMake(endX, endY) toPoint:CGPointMake(startX, startY) tailWidth:lineWidth headWidth:topHeight headLength:topHeight];
|
||||||
|
|
||||||
self.shapeLayer.path = path.CGPath;
|
self.shapeLayer.path = path.CGPath;
|
||||||
self.strokeLayer.path = path.CGPath;
|
self.strokeLayer.path = path.CGPath;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user