ios - 在 Swift 中为对象设置动画?

标签 ios xcode animation swift

在 swift 中,我正在将一个对象转换到 View 中,我需要它滑入或淡入。如何在我的程序中获得这种类型的动画?

我的所有 View 元素都是在没有 IB(界面生成器)的情况下以编程方式制作的

是否有可供我引用的文档?我找不到。

最佳答案

我习惯于使用 [UIView animateWithDuration ...],但我发现一开始将 block 语法切换到 Swift 有点棘手。这是一个快速的惰性代码:

view.alpha = 0.0
UIView.animateWithDuration(0.25, animations: {
    view.alpha = 1.0
}, completion: {
    (value: Bool) in
    println(">>> Animation done.")
})

关于ios - 在 Swift 中为对象设置动画?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24110706/

相关文章:

ios - CMTime 不寻求 AVPlayer 来校正时间

ios - 取消 IBAction 的滑动手势触发 Segue

iOS 在模拟器中工作,在 iphone 上通过 xcode 但在通过 itunes 复制存档时崩溃

iOS:谷歌地图 API - markerInfoWindow 与 markerInfoContents

ios - 键盘在出现时隐藏 UITextView

ios - NSURL请求错误: "[CoreData length]: unrecognized selector sent to instance"

ios - 是否可以在 Xcode 中为 SpriteKit 打开现场调试绘图?

android - Android SDK 中的 overridePendingTransition 不起作用

机器人 : moving Image one point to another point

javascript - 向左溢出 :hidden doesn't work on . animate(),但向右有效?