【发布时间】:2015-06-20 05:59:18
【问题描述】:
我正在使用NSTimer 每秒更新UIButton 的标题。
它可以工作,但标题中的文本会自动闪烁(动画为 alpha 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)?
标签: ios objective-c swift animation uibutton