OGeek|极客世界-中国程序员成长平台

标题: ios - iOS 上更强的阴影 [打印本页]

作者: 菜鸟教程小白    时间: 2022-12-11 19:31
标题: ios - iOS 上更强的阴影

我正在尝试用一些发光效果为按钮设置动画。

到目前为止,这是我得到的:

self.glowLayer = [[CALayer alloc] init];
self.glowLayer.contents = (__bridge id _Nullable)(self.currentBackgroundImage.CGImage);
self.glowLayer.opacity = 0; // set to 1 with animation.
self.glowLayer.shadowColor = [UIColor vtoPinkColor].CGColor;
self.glowLayer.shadowOffset = CGSizeZero;
self.glowLayer.shadowRadius = 5;
self.glowLayer.shadowOpacity = 1;
self.glowLayer.rasterizationScale = [UIScreen mainScreen].scale;
self.glowLayer.shouldRasterize = YES;
[self.layer addSublayer:self.glowLayer];

但是,我发现发光效果不够强。 当然,我可以更改阴影半径以使其更宽,但这只会使阴影“稀释”而不是变得更强。

enter image description here

我应该如何进行?



Best Answer-推荐答案


改变值 self.glowLayer.shadowOpacity 1 将为您工作。 并尝试 Translucent = No

关于ios - iOS 上更强的阴影,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43488262/






欢迎光临 OGeek|极客世界-中国程序员成长平台 (http://ogeek.cn/) Powered by Discuz! X3.4