I want to use animation to imageview using UIanimationtransitioncurl right or left. Is it possible?

前端 未结 1 1040
北恋
北恋 2020-12-03 16:38

I want to animate my photo gallery like the pages of the book. Is there any method with that I can use UIanimationtransitioncurl in either the left or right side?

Th

相关标签:
1条回答
  • 2020-12-03 17:21

    Yes, you can. This is the code I use for that,

        self.containerViewParent = [[[UIView alloc] initWithFrame:CGRectMake(what ever you want)] autorelease]; //Create a container parent for the container view.
    
        self.containerView = [[[UIView alloc] initWithFrame:GRectMake(what ever you want)] autorelease]; //Create a container view for the view you wish to display.
    
        CGAffineTransform rotate = CGAffineTransformMakeRotation(-3.14/2);
        [containerViewParent setTransform:rotate]; //Rotate the containerViewParent.
    
        [self.view addSubview:containerViewParent];//Add it to the main view.
    
        rotate = CGAffineTransformMakeRotation(3.14/2);
        [containerView setTransform:rotate];//Rotate the containerView.
    
        [self.containerViewParent addSubview:containerView]; //Add it to the self.containerViewParent.
        [self.containerView addSubview:viewToDisplay]; //Add the view you want to display.
    

    And then apply the transition to the parent view,

        [UIView beginAnimations:@"page transition" context:nil];
        [UIView setAnimationDuration:2.0];
        [UIView setAnimationTransition:UIViewAnimationTransitionCurlUp forView:self.containerView cache:YES];
        [UIView commitAnimations];
    

    It will curl to the left or the right when you curl up and down.

    **Note that you will need to play with the offset of the views to make it display correctly, but it works great for me.

    0 讨论(0)
提交回复
热议问题