对于iphone开发,如何翻转UIImageView?

zho*_*shu 3 iphone cocoa-touch

我想翻转一个imageView(左/右),但我找不到UIView(或UIImageView)方法来做到这一点?任何的想法?

谢谢!

Joe*_*ppo 16

我认为你唯一想要的是:

UIView的的

+ (void)setAnimationTransition:(UIViewAnimationTransition)transition forView:(UIView *)view cache:(BOOL)cache;
Run Code Online (Sandbox Code Playgroud)

UIViewAnimationTransitionFlipFromLeft,
UIViewAnimationTransitionFlipFromRight,
Run Code Online (Sandbox Code Playgroud)

这些动画过渡只能在动画块中使用.在容器视图上设置转换,然后换出旧视图以用于新视图,然后提交动画.

喜欢:

CGContextRef context = UIGraphicsGetCurrentContext();

[UIView beginAnimations:nil context:context];
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft forView:yourContainerView cache:YES];
[yourContainerView exchangeSubviewAtIndex:0 withSubviewAtIndex:1];
[UIView commitAnimations];
Run Code Online (Sandbox Code Playgroud)