lundi 25 avril 2016

iOS, random swipe with animation

How to make a random swipe with animation. Right now it's swiping but the new image is not appearing while swiping.

- (void)swipeToTheRight:(UISwipeGestureRecognizer *)gestureRecognizer
{

        NSLog(@"Swiped to the right");
        [UIView animateWithDuration:0.5
                         animations:^{
                             [UIView beginAnimations:@"" context:nil];
                             [UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft forView:self.view cache:YES];
                             [UIView setAnimationDuration:1.0f];
                             [UIView commitAnimations];
                             [self.myImage setImage:[UIImage imageNamed:[images objectAtIndex:quoteIndex]]];
                             [self.view setNeedsUpdateConstraints];
                         }]; 
}

SwipeToTheLeft

- (void)swipeToTheLeft:(UISwipeGestureRecognizer *)gestureRecognizer
{

        NSLog(@"Swiped to the left");
        [UIView animateWithDuration:0.5
                         animations:^{
                             [UIView beginAnimations:@"" context:nil];
                             [UIView setAnimationTransition:UIViewAnimationTransitionFlipFromRight forView:self.view cache:YES];
                             [UIView setAnimationDuration:1.0f];
                             [UIView commitAnimations];
                             [self.myImage setImage:[UIImage imageNamed:[images objectAtIndex:quoteIndex]]];
                             [self.view setNeedsUpdateConstraints];
                         }];


@end




Aucun commentaire:

Enregistrer un commentaire