美文网首页
iOS-宏定义-颜色设置

iOS-宏定义-颜色设置

作者: 一位不愿透露姓名的王先生_ | 来源:发表于2016-06-26 22:07 被阅读461次
    1. RGB颜色 + A透明度
        /** RGB颜色 + A透明度 */
        #define HQRGBAColor(r, g, b, a) [UIColor colorWithRed:(r) / 255.0 green:(g) / 255.0 blue:(b) / 255.0 alpha:(a)]
    
    2. RGB颜色
        /** RGB颜色 */
        #define HQRGBColor(r, g, b)     HQRGBAColor(r, g, b, 1.0)
    
    3. 随机色
        /**
         * 随机色
         * 注意下面是(256),(0 ~ 255)一共256种颜色
         * 如果写成(255)就失去了(r:255, g:255, b:255)这个最纯洁的白色
         */
        #define HQRandomColor           [UIColor colorWithRed:arc4random_uniform(256) / 255.0 green:arc4random_uniform(256) / 255.0 blue:arc4random_uniform(256) / 255.0 alpha:1.0]

    相关文章

      网友评论

          本文标题:iOS-宏定义-颜色设置

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