本文介绍了模糊UIPickerView的背景的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! 当点击 UITableViewCell 时,我显示一个 UIPickerView 我试图添加 UIVisualEffectView 到pickerView给它一个模糊的背景。我 尝试获得的是: https://www.evernote.com/shard/s111/sh/645d307f-c597-4dfa- 890f-9404ed297e71 / fd738fdf15cd956fcfa917e4311bfd1b 我是 其实 > https://www.evernote.com/shard/s111/sh/27440e85-2181-49e1-89e0-4b57e0ce3783/e6e2abae0edfb705e915b03e1b37e008 这里是代码我使用创建模糊并将其附加到选择器: UIBlurEffect * blurEffect = [UIBlurEffect effectWithStyle:UIBlurEffectStyleDark] ; UIVisualEffectView * blurEffectView = [[UIVisualEffectView alloc] initWithEffect:blurEffect]; [blurEffectView setFrame:_myPicker.frame]; [_myPicker addSubview:blurEffectView]; [_myPicker sendSubviewToBack:blurEffectView];请注意,即使调用 sendSubviewToBack , $ b 在选项轮前面 。如果我仔细查看,当我滚动视图,我可以看到选项移动后面的模糊。 如何正确地获得模糊背景和选项轮顶部?解决方案由于您不知道UIPickerView的确切视图层次结构,给你的pickerView clearColor 作为backgroundColor,并将选择器视图作为您的blurEffectView的子视图。这是正确的方法。 I am displaying a UIPickerView when tapping on a UITableViewCell. I am trying to add a UIVisualEffectView to the pickerView to give it a blurred background. What I'm trying to get is this:https://www.evernote.com/shard/s111/sh/645d307f-c597-4dfa-890f-9404ed297e71/fd738fdf15cd956fcfa917e4311bfd1bWhat I'm actually getting is this:https://www.evernote.com/shard/s111/sh/27440e85-2181-49e1-89e0-4b57e0ce3783/e6e2abae0edfb705e915b03e1b37e008Here is the code I'm using to create the blur and attach it to the picker:UIBlurEffect *blurEffect = [UIBlurEffect effectWithStyle:UIBlurEffectStyleDark];UIVisualEffectView *blurEffectView = [[UIVisualEffectView alloc] initWithEffect:blurEffect];[blurEffectView setFrame:_myPicker.frame];[_myPicker addSubview:blurEffectView];[_myPicker sendSubviewToBack:blurEffectView];Notice that even with the call to sendSubviewToBack, this ends up putting the blur in front of the option wheel. If I look carefully when I scroll the view, I can see the options moving behind the blur.How do I get the blur properly in the background and the option wheel on top? 解决方案 As you do not know the exact view hierarchy of a UIPickerView I would simply recommend to give your pickerView clearColor as backgroundColor and to put the picker view as subview of your blurEffectView. This would be the right way to do this. 这篇关于模糊UIPickerView的背景的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!