gpt4 book ai didi

ios - swift 如何让动画在两个 UIView 之间翻转

转载 作者:可可西里 更新时间:2023-11-01 01:40:39 25 4
gpt4 key购买 nike

我正在尝试创建一个 IOS 应用程序并在按下某些按钮时翻转两个 View 。我找到了翻转动画,但我希望翻转在翻转 90° 时将内容更改为新 View ,而不是在动画完成时。这是我的功能:

func animationFlip(fromView:UIView, toView:UIView, animationTime:Float)
{

UIView.animateWithDuration(NSTimeInterval(animationTime), animations: {

UIView.setAnimationTransition(UIViewAnimationTransition.FlipFromRight, forView: fromView, cache: true)

},completion:{completion in
UIView.animateWithDuration(NSTimeInterval(animationTime), animations: { () -> Void in

fromView.hidden = true;
toView.hidden = false;
UIView.setAnimationTransition(UIViewAnimationTransition.FlipFromRight, forView: toView, cache: true)


})
})
}

我发现这段代码似乎可以解决问题,但它是用 obj-c 编写的。如何翻译成swift?

[UIView transitionFromView:viewToReplace
toView:replacementView
duration:1
options:UIViewAnimationOptionTransitionFlipFromBottom
completion:nil];

提前致谢!

最佳答案

在 Swift 中:-

UIView.transitionFromView(viewToReplace, toView: replacementView, duration: 1, options: .TransitionFlipFromBottom, completion: { _ in })

关于ios - swift 如何让动画在两个 UIView 之间翻转,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30153648/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com