zoukankan      html  css  js  c++  java
  • 随机色

    #import "AppDelegate.h"

    #import "code-ViewController.h"

    @interface AppDelegate ()

     

    @end

     

    @implementation AppDelegate

     

    - (void)dealloc

    {

        [_window release];

        [super dealloc];

    }

     

    - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {

        self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease];

        // Override point for customization after application launch.

        self.window.backgroundColor = [UIColor whiteColor];

        

        code_ViewController *code = [[code_ViewController alloc]init];

        self.window.rootViewController = code;

        [code release];

     

        [self.window makeKeyAndVisible];

        return YES;

    }

     

     

     

    #import "code-ViewController.h"

    #import "TouchView.h"

    @interface code_ViewController ()

     

    @end

     

    @implementation code_ViewController

     

    - (void)viewDidLoad {

        [super viewDidLoad];

        // Do any additional setup after loading the view.

        

        TouchView *view = [[TouchView alloc] initWithFrame:[[UIScreen mainScreen]bounds]];

        view.backgroundColor = [UIColor blueColor];

        [self.view addSubview:view];

        [view release];

       

    }

     

    - (void)didReceiveMemoryWarning {

        [super didReceiveMemoryWarning];

        // Dispose of any resources that can be recreated.

     

    }

     

     

     

     

    #import "TouchView.h"

     

    @implementation TouchView

     

     

    // 取随机颜色

    - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event

    {

        int random1 = arc4random() % 256;

        int random2 = arc4random() % 256;

        int random3 = arc4random() % 256;

        

        self.backgroundColor = [UIColor colorWithRed:random1/255.0 green:random2/255.0 blue:random3/255.0 alpha:1.0];

    }

     

  • 相关阅读:
    Explain用法
    轻量快速的 Python ASGI 框架 uvicorn
    conda常用命令
    ubuntu 安装并配置zsh
    ubuntu安装zsh终端
    /etc/profile、/etc/bashrc、.bash_profile、.bashrc
    python用List的内建函数list.sort进行排序
    python对象排序
    修改python接口返回给前端的格式封装
    linux设置uwsgi开机自启
  • 原文地址:https://www.cnblogs.com/jx451578429/p/4751291.html
Copyright © 2011-2022 走看看