开发者

Displaying only plain colors

I'm trying to display a gradient using CAGradientLayers.

I just set two colors and i expect to see a gradient between them, unfortunately only the first plain color is displayed without any gradient.

Here is my code:

- (void)viewDidLoad {
[super viewDidLoad];

CAGradientLayer *gradientLayer = [CAGradientLayer layer];
gradientLayer.frame = CGRectMake(0.0, 0.0, 480.0, 320.0);
gradientLayer.colors = [NSArray arrayWithObjects:
                        (id)[UIColor colorWithRed:0.0 green:0.0 blue:1.0 alpha:1.0].CGColor,
                        (id)[UIColor colorWithRed:0.85 green:0.85 blue:0.85 alpha:1.0].CGColor,
                        nil];
gradientLayer.startPoint = CGPointMake(0, 0);
gradientLayer.endPoint = CGPointMake(480, 320);

[self.view.layer addSublayer:gradientLayer];
}

Any help would be gre开发者_StackOverflow社区atly appreciated!


The endPoint property should be between 0.0 and 1.0.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜