Created
December 14, 2015 08:42
-
-
Save lynxerzhang/56ac46fd28f0045cf819 to your computer and use it in GitHub Desktop.
Revisions
-
lynxerzhang created this gist
Dec 14, 2015 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,17 @@ //Jared Davidson's Random Colorization //run in xcode7.1 and swift2.1 //drand48返回0 - 1的随机Double数值 var red = CGFloat(drand48()) var green = CGFloat(drand48()) var blue = CGFloat(drand48()) var view = UIView(frame: CGRect(x: 0, y: 0, width: 100, height: 100)) //随机色 view.backgroundColor = UIColor(red: red, green: green, blue: blue, alpha: 1.0) //根据对应的red,green,blue数值返回UIColor对象(0 - 255) func rgbColor(red: Int, _ green: Int, _ blue: Int) -> UIColor { return UIColor(red: CGFloat(red) / 0xFF, green: CGFloat(green) / 0xFF, blue: CGFloat(blue) / 0xFF, alpha: 1.0) } view.backgroundColor = rgbColor(255, 255, 0) //纯黄色的背景