Ios 按钮模糊不起作用
我如何制作一个模糊的按钮?按钮后面是一个图像 这是我的代码:Ios 按钮模糊不起作用,ios,swift,xcode,uiblureffect,Ios,Swift,Xcode,Uiblureffect,我如何制作一个模糊的按钮?按钮后面是一个图像 这是我的代码: let blur = UIVisualEffectView(effect: UIBlurEffect(style: UIBlurEffectStyle.regular)) blur.frame = cell.lvlBut.bounds blur.isUserInteractionEnabled = false blur.layer.cornerRadius = 0.5 *
let blur = UIVisualEffectView(effect: UIBlurEffect(style: UIBlurEffectStyle.regular))
blur.frame = cell.lvlBut.bounds
blur.isUserInteractionEnabled = false
blur.layer.cornerRadius = 0.5 * cell.lvlBut.bounds.size.width
blur.clipsToBounds = true
cell.lvlBut.insertSubview(blur, at: 0)
模糊效果并不完美,请参见下图
只需根据您的要求设置按钮的
背景色
及其不透明度
只需根据您的要求设置按钮的
背景色
及其不透明度