随机数的问题

来源:互联网 发布:ug编程教学视频下载 编辑:程序博客网 时间:2024/05/19 12:11

        

随机数的问题:

    arc4random()

        int a = arc4random()%3; 一般是取余求随机数    arc4random_uniform()        int a = arc4random_uniform(23); 生成 23以下的随机数

生成随机的颜色:

 - (UIColor *)colorRandom        {            UIColor *color = [UIColor colorWithRed:arc4random_uniform(256)/255.0 green:arc4random_uniform(256)/255.0 blue:arc4random_uniform(256)/255.0 alpha:1.0];            return color;        }

0 0
原创粉丝点击