gpt4 book ai didi

iphone - 在 UIView 周围创建光晕

转载 作者:太空狗 更新时间:2023-10-30 03:40:09 27 4
gpt4 key购买 nike

我想在距离实际 UIView 本身大约 5px 的 UIView 周围绘制发光边框。

你能告诉我如何实现吗?

最佳答案

可能最简单的方法是创建阴影,但使用浅色而不是深色。阴影细节可以在这里找到:How do I draw a shadow under a UIView?here .

像这样的事情应该开始:

- (void)drawRect:(CGRect)rect
{
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextSaveGState(context);
CGContextSetShadowWithColor(context, CGSizeMake(0, 0), 10,
[UIColor whiteColor].CGColor);
[super drawRect:rect];
CGContextRestoreGState(context);
}

更新: 我刚试过这个。您必须在发光 View 的 super View 上使用此代码才能使其正常工作。

关于iphone - 在 UIView 周围创建光晕,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5291546/

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