如何在縱向發生方向更改時使用self.view.backgroundColor = self.randomColor;
, 更改視圖控制器的顏色?將方向從垂直向上顛倒時更改控制器的顏色
隨機色法:
-(UIColor *)randomColor
{
CGFloat hue = (arc4random() % 256/256.0); // 0.0 to 1.0
CGFloat saturation = (arc4random() % 128/256.0) + 0.5; // 0.5 to 1.0, away from white
CGFloat brightness = (arc4random() % 128/256.0) + 0.5; // 0.5 to 1.0, away from black
UIColor *color = [UIColor colorWithHue:hue saturation:saturation brightness:brightness alpha:1];
return color;
}
你所說的 「可逆」 是什麼意思?你的意思是[「顛倒」](https://developer.apple.com/library/ios/documentation/UIKit/Reference/UIApplication_Class/#//apple_ref/c/econst/UIInterfaceOrientationPortraitUpsideDown)? –
「倒置方向」 –