Changing leftBarButtonItem with flip transition?

此生再无相见时 提交于 2019-12-21 20:24:03

问题


In my code I programmatically change leftBarButtonItem with a UIButton to a UIActivityIndicatorView, I would like to know how to perform a flip transition when changing, any idea ?

Thanks a lot.


回答1:


Hmm.. I have a feeling that to do a flip transition, you need to have a UIView.

So.. you could make a custom barButtonItem and add to it a flipView:

UIView *flipView = [[UIView alloc] init....];
BarButtonItem *barbutton = [[BarButtonItem alloc] initWithCustomView:flipView];

then add your original view to the flipView, this can contain whatever you like...

[flipView addSubview:<original view>];

Then to flip this into a UIActivityIndicatorView, I think you need to do something like this:

[UIView beginAnimations:@"flip" context:NULL];
[UIView setAnimationDuration:1];
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft forView:flipView cache:YES];

[<original view> removeFromSuperView];
[flipView addSubview:<activityIndicatorView>];

[UIView commitAnimations];

You'll probably have to keep a reference to your flipView somewhere so you can bring back a reference to it when you want to perform the flip.

Hope this helps!

Nick.




回答2:


Take a look at the Elements sample. They are doing a flip in a toolbar there.



来源:https://stackoverflow.com/questions/614988/changing-leftbarbuttonitem-with-flip-transition

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!