Reputation: 11201
Is there a way to find the endpoint
of the screen? Let's say a screen of size (100x100) have the midpoint at (50,) and starting point (0,) and the endpoint as (100,). I can hard code to get the end point based on the device screen size, but that would be a too much work based on assumptions.
I am making a custom UIView
animation based on UIBezierPath
.
Here is what I am trying to do:
As you can see the animation is stopped after it reaches some point.And I want this point to be the end of the screen,so that UIView
is covered whole screen
. To be more clear, I drag the UIView
to point A, and it animates to point B (end point,so B>A)
I am not sure how to calculate B, so that when I drag UIView
to A, it animates to the end of the screen (endpoint of the screen).
Here is the code to get better understanding:
- (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) {
}];
}
Upvotes: 0
Views: 1447
Reputation: 2837
The endpoint of screen is equal to it's width and height:
CGSize screenSize = [UIScreen mainScreen].bounds.size;
CGPoint endPoint = CGPointMake(screenSize.width, screenSize.height);
Upvotes: 2