how can I animate the UINavigationBar background change on UIViewController push?

前端 未结 1 1858
误落风尘
误落风尘 2021-01-12 03:24

My app uses two different backgrounds for the UINavigationBar to indicate to the user what level in the hierarchy they\'re at. When I push a UIViewController that needs the

相关标签:
1条回答
  • 2021-01-12 03:34

    I know this is an old thread, but this worked for me:

    CATransition *transition = [CATransition animation];
    transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseOut];
    transition.type = kCATransitionFade;
    transition.duration = 0.5;
    
    [self.navigationController.navigationBar.layer addAnimation:transition forKey:nil];
    [self.navigationController.navigationBar setBackgroundImage:[[UIImage imageNamed:@"navigationbar.png"]resizableImageWithCapInsets:UIEdgeInsetsMake(44, 20, 44, 20)] forBarMetrics:UIBarMetricsDefault];        
    

    Place this inside your viewDidLoad method. You'll need to link/import the QuartzCore framework.

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