【发布时间】:2015-04-23 04:57:21
【问题描述】:
我已将 UIView 背景颜色设置为 CAGradient 图层,效果很好。我正在尝试在应用程序运行时更改此渐变。如果我关闭并重新加载应用程序,则会应用新的渐变,但我希望它在运行时工作。
CAGradientLayer *gradient = [CAGradientLayer layer];
gradient.frame = self.backGroundView.bounds;
gradient.colors = [NSArray arrayWithObjects:(id)[[UIColor whiteColor] CGColor], color.CGColor, nil];
[self.backGroundView.layer insertSublayer:gradient atIndex:0];
[self.backGroundView setNeedsDisplay];
self.backGroundView.contentMode = UIViewContentModeRedraw;
我已经尝试了 setNeedsDisplay 和 UIViewContentModeRedraw,但在应用程序运行时都没有更新 UIview 背景?
【问题讨论】:
标签: ios objective-c xcode uiview