1
A
回答
3
你會發現這是很有幫助的,這個片段在挑選每random
3.5秒的顏色和動畫化從什麼都它是目前到新的backgroundColor
。
- (void)viewDidLoad
{
[super viewDidLoad];
NSTimer *myTimer = [NSTimer scheduledTimerWithTimeInterval: 3.5
target: self
selector: @selector (updateBackgroundColor)
userInfo: nil
repeats: YES]];
}
- (void) updateBackgroundColor {
[UIView beginAnimations: nil context: nil];
[UIView setAnimationDuration: 3.0];
CGFloat redLevel = rand()/(float) RAND_MAX;
CGFloat greenLevel = rand()/(float) RAND_MAX;
CGFloat blueLevel = rand()/(float) RAND_MAX;
myButton.backgroundColor = [UIColor colorWithRed: redLevel
green: greenLevel
blue: blueLevel
alpha: 1.0];
[UIView commitAnimations];
}
相關問題
- 1. 按鈕上的顏色隨時變化
- 2. 隨機顏色隨着細胞的變化而變化Interior.Color
- 3. BufferedImage顏色變化
- 4. jquery顏色變化
- 5. AS3顏色變化
- 6. 顏色變化onhover?
- 7. GetCurrentApplicationCallbackUri隨時間變化
- 8. 按鈕顏色變化時不變
- 9. 隨着時間改變文字顏色
- 10. 用jQuery滾動動態顏色變化
- 11. 隨着系統時區的變化,VCal時間變化
- 12. javafx圖像顏色變化
- 13. Swing Panels顏色變化
- 14. SVG圖像變化顏色
- 15. Chart.js顏色沒有變化
- 16. PHP背景顏色變化
- 17. 顏色變化與輸入
- 18. jQuery的顏色變化
- 19. Animate顏色變化轉換
- 20. 鏈接顏色變化
- 21. Groupbox邊框顏色變化
- 22. iOS層顏色變化
- 23. Android按鈕顏色變化
- 24. gtkbutton字體顏色變化
- 25. 網格顏色變化
- 26. 顏色變化代碼
- 27. MenuItem的顏色變化
- 28. 文本顏色變化(8086)
- 29. 變化瓷磚顏色
- 30. 窗體顏色變化
[自setBackgroundColorTimer:的NSTimer scheduledTimerWithTimeInterval:1.0 --->這行代碼被撞壞.....錯誤顯示setBackgroundColorTimer:]:無法識別的選擇發送到實例0x4b159b0' 那樣 – iCrazyDev 2012-07-17 05:56:56
@rajeshkumar抱歉在我的答案中嘗試編輯的代碼。 – 2012-07-17 06:00:17
@rajeshkumar請記住,修改定時器間隔意味着你將不得不調整「[UIView setAnimationDuration:3.0]; 」來匹配它。 – 2012-07-17 06:05:25