iPhone CATransition adds a fade to the start and end of any animation?

前端 未结 3 1671
無奈伤痛
無奈伤痛 2020-12-10 06:07

So I am just beginning recently developing some simple apps for the iphone. I will say that I am fairly sure I don\'t have a strong understanding of programming for multiple

相关标签:
3条回答
  • 2020-12-10 06:13

    I was able to get the views to transition without fading at the beginning and end by using UIView animation. NOTE: In the code below, I have a UINavigationController and a UITabBarController inside a main UIView. The main UIVIew (containerView) is what I added as a subView to the Application window. The other two are subviews of the containerView.

    UITabBarController *tabBarController = [(AppDelegate_iPhone *)[[UIApplication sharedApplication] delegate] tabBarController];
    UIView *containerView = [(AppDelegate_iPhone *)[[UIApplication sharedApplication] delegate] containerView];
    UINavigationController *accountsNavigationController = [(AppDelegate_iPhone *)[[UIApplication sharedApplication] delegate] accountsNavigationController];
    
    CGRect accountsNavigationControllerEndFrame = containerView.frame;
    CGRect tabBarControllerEndFrame = CGRectMake(containerView.frame.size.width, containerView.frame.origin.y, containerView.frame.size.width, containerView.frame.size.height);
    [UIView beginAnimations:nil context:nil];
    [UIView setAnimationDuration:0.4];
    tabBarController.view.frame = tabBarControllerEndFrame;
    accountsNavigationController.view.frame = accountsNavigationControllerEndFrame;
    [UIView commitAnimations];
    
    0 讨论(0)
  • 2020-12-10 06:18

    I have never been able to find a solution to this problem, but I can offer a reasonable workaround. What's happening is it isn't fading to white, but fading to transparent, and the window background (or whatever view is behind) is white. There are a couple ways to get around this:

    1. Change the window background color. If both views you're fading between have the same solid background color, then this will look pretty good.

    2. Don't render a background in each view ("MenuView," for example), but rather have a shared background view that's under those views at all times.

    Note that this will not work in all circumstances -- grouped UITableViews, for example, are always completely opaque.

    (As I side note, I assume that you aren't build a navigation-based application, in which case all the animation should be handled automatically.)

    You also might want to consider the looking into the UIView method setAnimationTransition:forView:cache: if you haven't already as another way to transition between views (although it cannot do a sliding animation, if you are set on that).

    0 讨论(0)
  • 2020-12-10 06:25

    I solved this by enclosing the view to which I have applied the effect into a superview and by setting the superview property "clip subviews". now the fade is "clipped" by the superview.

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