• 随机色


    #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];

    }

     

  • 相关阅读:
    js页面问题--(ing)
    tomcat9以后对,请求消息头的严格字符要求
    linux常用命令--(不断更新)
    怎么用wireshark看抓包文件
    关于h2的启动问题
    VUE-02 基本指令
    RecyclerView设置空视图
    SpringBoot-JPA删除不成功,只执行了查询语句
    关于RecyclerView(二)设置EmptyView
    关于RecyclerView(一)基本使用
  • 原文地址:https://www.cnblogs.com/jx451578429/p/4751291.html
Copyright © 2020-2023  润新知