繁体   English   中英

iOS设置阴影半径不起作用

[英]iOS Set shadow radius is not working

UILabel设置阴影半径不起作用。

[self.testLabel.layer setShadowColor:[[UIColor purpleColor] CGColor]];
[self.testLabel.layer setShadowOffset:CGSizeMake(3, 3)];
[self.testLabel.layer setShadowRadius:5.0f];
[self.testLabel.layer setMasksToBounds:YES];

我的代码(Google云端硬盘) https://drive.google.com/file/d/0B5UPvOBH3cqvOFlvZHhKdlNhb0E/view?usp=sharing

如果这是一个重复的问题,我很抱歉。 非常感谢。

因为[self.testLabel.layer setMasksToBounds:YES];

这个方法会使阴影不可见,你可以使用png / jpg格式制作阴影图像,并将一个将图像设置在textLabel下面的imageview使其工作。

你也应该将不透明度设置为1 ..

//    self.testLabel.backgroundColor = [UIColor grayColor];
    self.testLabel.layer.shadowOpacity = 1.0f;
    [self.testLabel.layer setShadowColor:[[UIColor yellowColor] CGColor]];
    [self.testLabel.layer setShadowOffset:CGSizeMake(3, 3)];
    [self.testLabel.layer setShadowRadius:5.0f];
//    [self.testLabel.layer setMasksToBounds:YES];

尝试这个 ..

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM