Transitioning UINavigationBar colors?

后端 未结 3 628
名媛妹妹
名媛妹妹 2020-12-30 17:43

I\'m basically trying to duplicate the behavior of the iPod app on the iPhone, where when you select a song, the music player view slides in, and the navigation bar transiti

3条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-12-30 18:27

    I cooked a solution that might be more what you're looking for.

    • Create a custom subclass of UINavigationBar.
    • Override setBarStyle: as follows

    code:

    - (void)setBarStyle:(UIBarStyle)style {
        //Fade our content, ie background, from one style to another
        CATransition *transition = [[CATransition new] autorelease];
        transition.type = kCATransitionFade;
        transition.duration = 0.2;
        [self.layer addAnimation:transition forKey:@"content"];
    
        [super setBarStyle:style];
    }
    
    • Configure your nav controllers to use this subclass
      • In IB, you can just set the class in the inspector

提交回复
热议问题