美文网首页
<iOS 实践经验>生成随机颜色

<iOS 实践经验>生成随机颜色

作者: 貘鸣 | 来源:发表于2017-12-05 12:22 被阅读42次

比较好用的测试方法: 生成随机颜色

    static var randomColor: UIColor {// 随机颜色
        let red = CGFloat(arc4random() % 256) / 255.0
        let green = CGFloat(arc4random() % 256) / 255.0
        let blue = CGFloat(arc4random() % 256) / 255.0
        let color = UIColor(red: red, green: green, blue: blue, alpha: 1.0)
        return color
    }

相关文章

网友评论

      本文标题:<iOS 实践经验>生成随机颜色

      本文链接:https://www.haomeiwen.com/subject/ssoqixtx.html