gpt4 book ai didi

iphone - 我如何更改 Core Graphics 中 CALayer 的填充颜色?

转载 作者:可可西里 更新时间:2023-11-01 05:03:21 24 4
gpt4 key购买 nike

我有一个形状,一个 CALayer,我想向其添加核心图形效果。现在,我想保持简单并更改它的填充颜色。我该怎么做?

最佳答案

如果你只想改变整个图层的颜色,你可以使用:

layer.backgroundColor = [[UIColor greenColor] CGColor];

如果你有一个更复杂的形状,比如要填充的路径,你需要用这样的东西覆盖层的 drawInContext::

- (void)drawInContext:(CGContextRef)context
{
//...
CGContextSetFillColorWithColor(context, [[UIColor greenColor] CGColor]);
CGContextFillPath(context);
//...
}

参见 Quartz 2D Programming Guide了解更多信息。

关于iphone - 我如何更改 Core Graphics 中 CALayer 的填充颜色?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15959424/

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