swift – 为UIButton添加模糊效果
发布时间:2020-12-14 05:23:28 所属栏目:百科 来源:网络整理
导读:如何让按钮背景变得模糊? 我发现这会产生模糊效果: let blur = UIVisualEffectView(effect: UIBlurEffect(style: UIBlurEffectStyle.Light))blur.frame = buttonForDisabling.frameself.tableView.addSubview(blur) 这是有效的,但只能使用与我的按钮相同的
如何让按钮背景变得模糊?
我发现这会产生模糊效果: let blur = UIVisualEffectView(effect: UIBlurEffect(style: UIBlurEffectStyle.Light)) blur.frame = buttonForDisabling.frame self.tableView.addSubview(blur) 这是有效的,但只能使用与我的按钮相同的框架进行模糊处理.我想要一个背景模糊的按钮.在iOS8中可以吗?
这可以通过创建模糊并将其插入UIButton的titleLabel下方来完成.禁用用户交互非常重要,以便允许触摸不被视觉效果视图拦截并转发到按钮.
let blur = UIVisualEffectView(effect: UIBlurEffect(style: UIBlurEffectStyle.Light)) blur.frame = buttonForDisabling.bounds blur.userInteractionEnabled = false //This allows touches to forward to the button. buttonForDisabling.insertSubview(blur,atIndex: 0) (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |