日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

KaleidoscopeGame

發布時間:2025/3/21 编程问答 22 豆豆
生活随笔 收集整理的這篇文章主要介紹了 KaleidoscopeGame 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

?

//創建萬花筒視圖
?

for (NSInteger i = 0; i < 16; i++) {
??????? centerView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 300 - 20 * i, 300 - 20 * i)];
??????? centerView.center = self.window.center;
??????? centerView.layer.borderColor = [UIColor grayColor].CGColor;
??????? centerView.layer.borderWidth = 1;
??????? centerView.tag = 200 + i;
??????? centerView.layer.cornerRadius = 150 - i * 10;
??????? [self.window addSubview:centerView];
??????? [centerView release];
??? }
???
??? //創建控制按鈕
??? //啟動按鈕

??? UIButton *startButton = [UIButton buttonWithType:UIButtonTypeSystem];
??? startButton.frame = CGRectMake(150, 90, 75, 30);
??? startButton.backgroundColor = [UIColor grayColor];
??? [startButton setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
??? [startButton setTitle:@"啟動" forState:UIControlStateNormal];
??? startButton.titleLabel.font = [UIFont systemFontOfSize:25];
??? [startButton addTarget:self action:@selector(pressStartButton) forControlEvents:UIControlEventTouchUpInside];
??? [self.window addSubview:startButton];
??? //停止按鈕
??? UIButton *stopButton = [UIButton buttonWithType:UIButtonTypeSystem];
??? stopButton.frame = CGRectMake(150, 597, 75, 30);
??? stopButton.backgroundColor = [UIColor grayColor];
??? [stopButton setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
??? stopButton.titleLabel.font = [UIFont systemFontOfSize:25];
??? [stopButton setTitle:@"停止" forState:UIControlStateNormal];
??? [stopButton addTarget:self action:@selector(pressStopButton) forControlEvents:UIControlEventTouchUpInside];
??? [self.window addSubview:stopButton];

//需要用到的方法
//點擊button啟動萬花筒

- (void) pressStartButton {
??? //使用了定時器, 使視圖達到轉動的效果
??? myTimer = [NSTimer scheduledTimerWithTimeInterval:0.3 target:self selector:@selector(colorChange) userInfo:nil repeats:YES];
}

//點擊button停止萬花筒
- (void) pressStopButton {
??? //當定時器停止運轉的時候, 萬花筒的效果也就自然結束
??? [myTimer invalidate];
}

//為視圖隨機添加顏色, 并使靠內視圖的顏色賦給靠外視圖
- (void)colorChange {
??? for (NSInteger i = 15; i >= 0; i--) {
???????
??????? //使用tag值尋找到相應的視圖
??????? [self.window viewWithTag:214 - i].backgroundColor = [self.window viewWithTag:215 - i].backgroundColor;
??????? [self.window viewWithTag:215 - i].backgroundColor = [UIColor colorWithRed:arc4random() % 256 / 255. green:arc4random() % 256 / 255. blue:arc4random() % 256 / 255. alpha:arc4random() * 11 / 10.];
??? }
}

轉載于:https://www.cnblogs.com/zhangwu/p/4565630.html

總結

以上是生活随笔為你收集整理的KaleidoscopeGame的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。