3

I would like to change the content of my titleView in the navigationBar to display different kinds of information, for instance a UIsegmentedControl or a UILabel. The change of the information should be a done with a transition (segmentedControl fades out and label fades in).

I tried to add multiple UIViews in the titleView and animate the alpha value, but it's not working.

[self.navigationItem.titleView addSubview:_mainSegmentedControl];

So I tried to change the content during the animation but since the value can't be animated it will be called immediately:

[UIView animateWithDuration:0.2 animations:^{
     _filterSegmentedControl.alpha = 0.0f;} completion:^(BOOL finished) {
            [UIView animateWithDuration:0.3 animations:^{
                self.navigationItem.titleView = _mainSegmentedControl;
                _mainSegmentedControl.alpha = 1.0f;
            }];
}];

Any suggestions?

user2014551
  • 325
  • 5
  • 17
  • Have you tried just using one animation block setting `self.navigationItem.titleView = _mainSegmentedControl;` inside and providing the option `UIViewAnimationOptionTransitionCrossDissolve`? – luk2302 Aug 16 '15 at 20:28
  • `[UIView animateWithDuration:1.0 delay:0.0 options:UIViewAnimationOptionTransitionCrossDissolve animations:^{ self.navigationItem.titleView =_filterSegmentedControl; } completion:^(BOOL finished) { }];` works but just once. do i have to remove the view afterwards? – user2014551 Aug 16 '15 at 21:09

0 Answers0