【问题标题】:How can I make a UIView fade from a solid background color to clear background color?如何使 UIView 从纯色背景色淡化为清除背景色?
【发布时间】:2016-05-04 22:13:37
【问题描述】:

我知道有多种方法(CAAnimation、commitAnimations 等),但最简单的方法是什么?

我希望 UIView 从蓝色开始,然后在 X 毫秒内淡入淡出(或白色,更容易)。

【问题讨论】:

    标签: ios swift


    【解决方案1】:

    你可以使用UIView的动画方法。它比其他动画简单得多,但更有限。幸运的是,backgroundColor 是动画之一。示例:

    self.view.backgroundColor = UIColor.blueColor()
    
    UIView.animateWithDuration(1.0, animations: {
        self.view.backgroundColor = UIColor.clearColor()
    })
    

    【讨论】:

    • 同意使用 UIView 动画。 (投票)。比 CAAnimation 简单得多。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多