我有这段代码可以给 UIButton 添加阴影
layer.masksToBounds = false
layer.shadowColor = UIColor.black.cgColor
layer.shadowOffset = CGSize(width: 0, height: 1)
layer.shadowOpacity = 0.2
layer.shouldRasterize = true
它成功地为按钮添加了阴影,但也模糊了按钮图像 是否可以在不模糊按钮内容的情况下添加阴影?
最佳答案
您的代码没问题,只需删除行 layer.shouldRasterize = true 或将其设置为 False。
关于swift - UIButton 的阴影模糊了按钮图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44055204/