ios - UILabel 帧大小动画不适用于 ios8

标签 ios swift animation

当为 UILabel 帧大小变化设置动画时,它在 iOS9 上有效,但在 iOS8 上无效(在 iOS8 上它跳转到最终状态而不是动画)。使用 UIView 或 iOS9 时,此问题消失。

什么会导致这个问题? (您可以在 https://github.com/IdoNave/UIlabelAnimation 查看该项目)

class MyView: UIView {

var progrssLabel: UILabel?

func startProgreesAnimation(from: CGFloat, duration: Double) {
    if progrssLabel == nil {
        progrssLabel = UILabel(frame: CGRect(x: 0, y: 0, width: frame.width * from, height: frame.height))
        progrssLabel?.backgroundColor = UIColor.redColor()
        self.addSubview(progrssLabel!)
    }

    UIView.animateWithDuration(duration, delay: 0, options: UIViewAnimationOptions.CurveEaseInOut, animations: {
        self.progrssLabel!.frame = self.bounds
    }) { (finish) in
        print("ProgreesAnimation ended")
    }
}

最佳答案

在以下位置找到了此问题的原因和解决方案:https://stackoverflow.com/a/22224630/1105726 将标签添加到其他 View 并在 View 上运行动画解决了问题! (链接中有更多详细信息)

关于ios - UILabel 帧大小动画不适用于 ios8,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36857921/

相关文章:

javascript - animate.css 动画之间的延迟

ios - Swift UICollectionView 水平滚动单元格标签宽度根据标签内容长度动态变化

iphone - AVAudioPlayer 帮助 : Playing multiple sounds simultaneously, 一次停止它们,并解决自动引用计数

ios - 当 UITextField 的 "editingDidBegin"控件事件触发时,将 UITextField 的当前值设置为属性

swift - 如何创建 [AudioQuality : NSURL] 的字典

ios - swift 阿尔法颜色

在列表中的部分之间移动项目时,SwiftUI 奇怪的行为

jquery - 如何让图片在页面中随机移动并在移动时旋转 Angular (使用jQuery或CSS)

iOS:向下移动 UITextField 的底部边框

iphone - 带有动画启动画面的iPhone/iPad应用