到目前为止,我已经有了一个圆形的UIbutton,但我在网上找到的代码(我是iOS新手,我不是很了解模糊等是如何工作的)添加模糊只是将它作为整个按钮的框架,基本上使按钮再次显示为方形.
我也尝试添加一个视图,然后是UIbutton,然后是模糊效果,并将cornerRadius代码应用于该视图,但它也无效.
这是我尝试过的:
shortcutbutton.layer.cornerRadius = 0.5 * shortcutbutton.bounds.size.wIDth // add the round corners in proportion to the button size let blur = UIVisualEffectVIEw(effect: UIBlurEffect(style: UIBlurEffectStyle.light)) blur.frame = shortcutbutton.bounds blur.userInteractionEnabled = false //This allows touches to forward to the button. shortcutbutton.insertSubvIEw(blur,atIndex: 0)解决方法 在添加子视图之前,将以下两行代码添加到项目中:
blur.layer.cornerRadius = 0.5 * shortcutbutton.bounds.size.wIDthblur.clipsToBounds = true
请享用! 总结
以上是内存溢出为你收集整理的Swift:圆形UIButton,背景模糊全部内容,希望文章能够帮你解决Swift:圆形UIButton,背景模糊所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)