gpt4 book ai didi

ios - 添加CAGradient图层但无法获得渐变效果

转载 作者:行者123 更新时间:2023-11-29 00:36:42 24 4
gpt4 key购买 nike

这里我使用这段代码来提供渐变效果,但根本没有得到效果。

 CAGradientLayer *layer2 = [CAGradientLayer layer];

NSArray *gradientColors = [NSArray arrayWithObjects:(id)[self colorWithHexString:@"3eb79d"].CGColor,(id)[self colorWithHexString:@"3fb65c"].CGColor,(id)[self colorWithHexString:@"3cb7da"].CGColor, nil];

[layer2 setColors:gradientColors];
[layer2 setFrame:cell.userBackgroundView.layer.frame];
[cell.userBackgroundView.layer insertSublayer:layer2 atIndex:0];
cell.userBackgroundView.clipsToBounds = YES;

最佳答案

试试这个

CAGradientLayer *gradient = [CAGradientLayer layer];
gradient.frame =cell.userBackgroundView.frame;
gradient.colors = [NSArray arrayWithObjects:(id)[[UIColor clearColor] CGColor], (id)[[UIColor blackColor] CGColor], nil];
[cell.userBackgroundView.layer insertSublayer:gradient atIndex:0];

关于ios - 添加CAGradient图层但无法获得渐变效果,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40419443/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com