Questions tagged «cagradientlayer»

29
如何将渐变应用于iOS Swift App的背景视图
我正在尝试将渐变用作视图(情节提要的主视图)的背景颜色。该代码运行,但没有任何变化。我正在使用xCode Beta 2和Swift。 这是代码: class Colors { let colorTop = UIColor(red: 192.0/255.0, green: 38.0/255.0, blue: 42.0/255.0, alpha: 1.0) let colorBottom = UIColor(red: 35.0/255.0, green: 2.0/255.0, blue: 2.0/255.0, alpha: 1.0) let gl: CAGradientLayer init() { gl = CAGradientLayer() gl.colors = [ colorTop, colorBottom] gl.locations = [ 0.0, 1.0] } } 然后在视图控制器中: …

7
iOS白色到透明渐变层为灰色
我在此小细节视图的底部插入了一个CAGradientLayer,该视图会在应用程序的底部弹出。如您所见,我将颜色从白色设置为清晰,但是却出现了这种奇怪的灰色调。有任何想法吗? // Set up detail view frame and gradient [self.detailView setFrame:CGRectMake(0, 568, 320, 55)]; CAGradientLayer *layer = [CAGradientLayer layer]; layer.frame = self.detailView.bounds; layer.colors = [NSArray arrayWithObjects:(id)[UIColor whiteColor].CGColor, (id)[UIColor clearColor].CGColor, nil]; layer.startPoint = CGPointMake(1.0f, 0.7f); layer.endPoint = CGPointMake(1.0f, 0.0f); [self.detailView.layer insertSublayer:layer atIndex:0]; 这是有问题的视图:
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.