【代码笔记】背景色随机显示

时间:2015-12-03 09:50:43   收藏:0   阅读:341

一,效果图。

技术分享

二,工程图。

技术分享

三,代码。

RootViewController.h

RootViewController.m

技术分享
- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    self.title=@"背景颜色的随机显示";
    
}
//点击任何处,变换背景颜色
-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
    CGFloat red = (CGFloat)arc4random() / 0x100000000;
    CGFloat green = (CGFloat)arc4random() / 0x100000000;
    CGFloat blue = (CGFloat)arc4random() / 0x100000000;
    self.view.backgroundColor = [UIColor colorWithRed:red green:green blue:blue alpha:1.0f];
}
技术分享

 

原文:http://www.cnblogs.com/yang-guang-girl/p/5015031.html

评论(0
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!