I want to make a slide transition with transitionFromView

Asked 2 years ago, Updated 2 years ago, 39 views

The UIView#transitionFromView:toView:duration:options:completion:There are only limited animations, but I would like to have an animation that slides left and right like push transition.

ios objective-c

2022-09-29 22:52

2 Answers

Use the CATransition class in the Core Animation Framework (Quartz Core Framework).

CATransition Class Reference

Core Animation Programming Guide

Transition Animations Support Changes to Layer Visibility


2022-09-29 22:52

This is what push-like animation looks like.

 CATransaction begin;
    CATransaction setValue: (id)kCFBooleanTrue
                     forKey —kCATransactionDisableActions ;

    CATransition* transition= CATransition animation;
    transition.delegate=self;
    transition.duration=.4f;
    transition.timingFunction= [CAMediaTimingFunctionFunctionWithName:kCAMediaTimingFunctionEaseInEaseOut];
    transition.type =kCATtransitionPush;
    transition.subtype=(isRight)?kCATtransitionFromLeft:kCATtransitionFromRight;
    targetView.layer addAnimation:transition
                                     forKey:nil];

    CATransaction commit ;


2022-09-29 22:52

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.