- Java 双重比较
- java - 比较器与 Apache BeanComparator
- Objective-C 完成 block 导致额外的方法调用?
- database - RESTful URI 是否应该公开数据库主键?
我想创建一些在它们之间有延迟的动画,所以我决定使用 UIView.animateKeyframesWithDuration:delay:options:animations:completion:
。
问题是它同时发生。这是我的代码:
animateKeyframesWithDuration:
UIView.animateKeyframesWithDuration(5, delay: 0, options: nil, animations: {
UIView.addKeyframeWithRelativeStartTime(0, relativeDuration: 1/5, animations: {
self.flipTransition(container: self.container500, view1: self.button500, view2: self.buttonDivision)
})
UIView.addKeyframeWithRelativeStartTime(1/5, relativeDuration: 1/5, animations: {
self.flipTransition(container: self.container100, view1: self.button100, view2: self.buttonMultiplication)
})
UIView.addKeyframeWithRelativeStartTime(2/5, relativeDuration: 1/5, animations: {
self.flipTransition(container: self.container50, view1: self.button50, view2: self.buttonSubtraction)
})
UIView.addKeyframeWithRelativeStartTime(3/5, relativeDuration: 1/5, animations: {
self.flipTransition(container: self.container10, view1: self.button10, view2: self.buttonAddition)
})
UIView.addKeyframeWithRelativeStartTime(4/5, relativeDuration: 1/5, animations: {
self.flipTransitionForConvertAndEqual(container: self.containerConvert, convertView: self.buttonConvert, equalView: self.buttonEqual)
})
}, completion: { finished in
})
transitionWithView:
private func flipTransitionForConvertAndEqual(#container: UIView, convertView: UIView, equalView: UIView) {
var transitionOptions: UIViewAnimationOptions!
let duration = kAnimationDuration
// case where equal is displayed
if equalView.superview != nil {
transitionOptions = .TransitionFlipFromLeft
}
else {
transitionOptions = .TransitionFlipFromRight
}
UIView.transitionWithView(container, duration: duration, options: transitionOptions, animations: {
self.setConvertContainer(container: container, convertView: convertView, equalView: equalView)
}, completion: nil)
}
private func flipTransition(#container: UIView, view1: UIView, view2: UIView) {
var transitionOptions: UIViewAnimationOptions!
let duration = kAnimationDuration
var views : (frontView: UIView, backView: UIView)
if view1.superview != nil {
views = (frontView: view1, backView: view2)
transitionOptions = .TransitionFlipFromLeft
}
else {
views = (frontView: view2, backView: view1)
transitionOptions = .TransitionFlipFromRight
}
UIView.transitionWithView(container, duration: duration, options: transitionOptions, animations: {
self.addFrontViewToContainer(container, frontView: views.backView, backView: views.frontView)
}, completion: nil)
}
我做错了什么?想不通。
最佳答案
来自文档:
- (void)addKeyframeWithRelativeStartTime:(double)frameStartTime relativeDuration:(double)frameDuration animations:(void (^)(void))animations NS_AVAILABLE_IOS(7_0);
// start time and duration are values between 0.0 and 1.0 specifying time and duration relative to the overall time of the keyframe animation
在您的情况下,您可能希望为 relativeStartTime 参数 1 * (1/5)、2 * (1/5)、3 * (1/5) 和 1/5 表示持续时间,请记住这些是相对于您指定的总持续时间的值UIView.animateKeyframesWithDuration.. 方法
关于ios - UIView.animateKeyframesWithDuration 内的 UIView.transitionWithView 未按预期工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31910417/
我使用 animateKeyframesWithDuration 为我的 View 制作简单的动画: [UIView animateKeyframesWithDuration:1.0 delay:0.
我添加了一个连续运行的相对简单的动画。这用于短暂切换到另一个 View 几秒钟。 当动画运行时,iPhone 6 (iOS 9.2.1) 上的 GPU 从 <5% 跃升至恒定的 30-40%,而模拟器
我很困惑为什么这不起作用。我这三个事件接连发生。第一个缩小和缩小图像,第二个在背景中淡入淡出,第三个为第一张图像设置动画。但它实际上是反过来发生的吗?我做了什么傻事吗? [UIView ani
我正在尝试编写一个闪烁的动画,但感觉时间不对。我在 Playground 上做了一个简单的版本: import UIKit import XCPlayground let v = UIView() v
我尝试使用下面的代码在屏幕上创建一个连续旋转的正方形。但我不知道为什么转速在变化。我怎样才能改变代码使转速不变?我尝试了不同的 UIViewKeyframeAnimationOptions,但似乎都不
我有一个带有关键帧动画的 iOS 应用。最后一个关键帧即将结束时,我的应用程序崩溃并出现此错误: *** Terminating app due to uncaught exception 'NSR
我想在 View 中添加心跳效果,一种方法是使用 UIView 的动画方法,如下所示: - (void)heartBeating { UIView *panel; NSTimeInte
我想创建一些在它们之间有延迟的动画,所以我决定使用 UIView.animateKeyframesWithDuration:delay:options:animations:completion:。
我正在尝试创建一种效果,其中三个箭头交替地从可见变为不可见。 我做了一个简单的算法,其中每个箭头都从不同的 alpha 值开始(如果有 3 个箭头,第一个将从 alpha=1 开始,第二个从 alph
我最近发现了一些 UIView 动画代码,并注意到它没有正确使用 animateKeyframesWithDuration:delay:options:animations:completion: 方
我是一名优秀的程序员,十分优秀!