0

我有以下代码来创建渐变(或渐变的开始):

CAGradientLayer *gradient = [CAGradientLayer layer];


UIColor *lightGreen = [UIColor colorWithRed:66.0f/255.0f green:79.0f/255.0f blue:91.0f/255.0f alpha:1.0f];
UIColor *darkGreen = [UIColor colorWithRed:66.0f/255.0f green:79.0f/255.0f blue:91.0f/255.0f alpha:1.0f];

为什么这条线给我“预期的标识符”?

gradient.colors = [NSArray arrayWithObjects:(id)[lightGreen.CGColor]];
4

1 回答 1

1

你的代码中有很多[,而且你没有关闭, nil

gradient.colors = [NSArray arrayWithObjects:(id)[lightGreen.CGColor]];

应该:

gradient.colors = [NSArray arrayWithObjects:(id)lightGreen.CGColor, nil];

甚至:

gradient.colors = @[(id)lightGreen.CGColor];
于 2013-08-26T07:22:32.963 回答