我正在尝试创建一个 UIView 并更改其 alpha 属性以模拟背光变化。这是我的代码
TransparentView = [[UIView alloc] initWithFrame:self.view.bounds];
TransparentView.backgroundColor = [UIColor whiteColor];
self.view = TransparentView;
TransparentView.alpha = 0.2;
float step = 1.0 / ( appDelegate.OnOffTime * 100);
for (float f = 0; f < 1; f=f+step) {
TransparentView.alpha = (CGFloat)(1 - f);
[NSThread sleepForTimeInterval:0.01];
}
两者TransparentView.alpha = 0.2
都 TransparentView.alpha = (CGFloat)(1 - f)
改变TransparentView.alpha
了,但只TransparentView.alpha = 0.2
改变了真实设备的“亮度”。我做错了什么?