有没有办法找到屏幕的endpoint
?让我们说一个大小(100x100)的屏幕的中点位于(50,)和起点(0,),端点为(100,)。我可以根据设备屏幕大小来硬编码以获得终点,但这可能是基于假设的过多工作。
我正在制作基于UIView
的自定义UIBezierPath
动画。
以下是我要做的事情:
正如您所看到的,动画在到达某个点后停止了。我希望这一点成为屏幕的结尾,以便UIView
涵盖整个screen
。为了更清楚,我将UIView
拖到A点,然后它动画到B点(终点,所以B> A)
我不知道如何计算B,所以当我将UIView
拖到A时,它会动画到屏幕的末尾(屏幕的终点)。
以下是更好理解的代码:
- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event
{
UITouch *touch = [[event allTouches] anyObject];
CGPoint touchLocation = [touch locationInView:self.dragView];
if (touchLocation.x<250) {
if (!startBackSlide) {
_circleDragView.touchdragPoint=touchLocation.y;
_circleDragView.dragToPoint=CGPointMake(touchLocation.x+40, touchLocation.y);
[_circleDragView setNeedsDisplay];
_savedPoint=touchLocation;
}else{
//move the top and bot points backwards along with slide
[self animateCOmpleteBezier:touchLocation];
_circleDragView.touchdragPoint=touchLocation.y;
_circleDragView.dragToPoint=CGPointMake(touchLocation.x+54, touchLocation.y);
[_circleDragView setNeedsDisplay];
_savedPoint=touchLocation;
if (touchLocation.x<20) {
startBackSlide=NO;
snapped=YES;
}
}
}
if (touchLocation.x>=250) {
if (snapped) {
snapped=NO;
//move the top and bottom points to the specified point(In this case the end point)
}
}
}
-(void)animateCOmpleteBezier:(CGPoint) value{
[UIView animateWithDuration:0.01 delay:0 options:UIViewAnimationOptionCurveEaseOut animations:^{
_circleDragView.topWidthPoint=value.x-10;
_circleDragView.botWidthPoint=value.x-10;
[_circleDragView setNeedsDisplay];
} completion:^(BOOL finished) {
}];
}
答案 0 :(得分:2)
屏幕的终点等于它的宽度和高度:
CGSize screenSize = [UIScreen mainScreen].bounds.size;
CGPoint endPoint = CGPointMake(screenSize.width, screenSize.height);