将模糊视图添加到标签? [英] Add blur view to label?

查看:97
本文介绍了将模糊视图添加到标签?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何为标签添加模糊视图?标签位于UIImage的前面,我希望标签的背景模糊,以便用户可以更好地阅读文本.我在标签的边界内获得了模糊效果,但是文本本身消失了(也许也变得模糊了,这是为什么).我也尝试以编程方式添加标签,但没有成功.我感谢您提供的任何帮助!

How can I add a blur view to a label? The label is in front of a UIImage and I wanted the background of the label to be blurred, so that the user can read the text better. I get the Blur effect inside the bounds of the label, but the text itself disappears (maybe also gets blurred, idk why). I also tried to add a label programmatically, but I didn't get it working. I'm thankful for any kind of help!

let blur = UIBlurEffect(style: .Light)
    let blurView = UIVisualEffectView(effect: blur)

    blurView.frame = findATeamLabel.bounds
    findATeamLabel.addSubview(blurView)

推荐答案

您可以尝试将其发送到标签的视图层次结构的后面.试试

You could try sending it to the back of the view hierarchy for the label. Try

findATeamLabel.sendSubviewToBack(blurView)

这篇关于将模糊视图添加到标签?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆