【问题标题】:iOS Set shadow radius is not workingiOS设置阴影半径不起作用
【发布时间】:2015-02-11 02:27:44
【问题描述】:

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

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

【问题讨论】:

标签: ios uilabel shadow


【解决方案1】:

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

此方法将使阴影不可见,您可以使用 png/jpg 格式制作阴影图像,并将已设置图像的 imageview 放在 textLabel 下方以使其工作..

你还应该将不透明度设置为 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];

试试这个..

【讨论】:

  • 设置不透明度为我做了。谢谢!
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2011-05-17
  • 2021-06-16
  • 1970-01-01
  • 2012-05-10
相关资源
最近更新 更多