【发布时间】:2019-04-08 10:27:39
【问题描述】:
我正在尝试向 UIButton 添加阴影,但我只想为 UIButton 底部阴影添加阴影,而不是为其图像和标题添加阴影。我关注了UIButton bottom shadow,但没有成功。 基本上,这就是我现在所拥有的:
这是我当前的代码:
button.layer.borderWidth = 0.5
button.layer.borderColor = UIColor.gray.cgColor
button.layer.shadowColor = UIColor.black.cgColor
button.layer.shadowOffset = CGSize(width: 0, height: 2)
button.layer.shadowOpacity = 1.0
button.layer.shadowRadius = 0
button.layer.masksToBounds = false
请帮忙。提前致谢。
【问题讨论】:
-
看起来您的按钮具有透明背景,将其背景更改为白色应该可以解决问题。