美文网首页
随机颜色,随机数

随机颜色,随机数

作者: 么么木木 | 来源:发表于2017-02-06 13:48 被阅读17次
    [UIColor colorWithRed:arc4random_uniform(256)/255.0 
    
                green:arc4random_uniform(256)/255.0 
    
                blue:arc4random_uniform(256)/255.0 alpha:0.3]
    

    随机数函数arc4random_uniform(x),可以用来产生0~(x-1)范围内的随机数。如果要生成1~x的随机数:arc4random_uniform(x)+1

    相关文章

      网友评论

          本文标题:随机颜色,随机数

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