我正在使用 NSTimer
每秒更新一个 UIButton
的标题。
它能够工作,但是标题中的文本会自动闪烁(透明度动画到0
,然后回来)。
我尝试使用 button.layer.removeAllAnimations()
但没有成功,也没有异常,因此似乎已正确链接了QuartzCore。
当前无法正常工作的警惕代码:
UIView.setAnimationsEnabled(false)
UIView.performWithoutAnimation {
button.setTitle(time, forState: .Normal)
button.layer.removeAllAnimations()
}
UIView.setAnimationsEnabled(true)
UIView
的performWithoutAnimation(_ actionsWithoutAnimation: () -> Void)
(iOS >= 7)或者setAnimationsEnabled(_ enabled: Bool)
来包装它吗? - zrzka