菜鸟教程小白 发表于 2022-12-13 05:29:59

ios - 模糊 UIPickerView 背景


                                            <p><p>点击 <code>UITableViewCell</code> 时,我正在显示 <code>UIPickerView</code>。我正在尝试将 <code>UIVisualEffectView</code> 添加到 pickerView 以使其背景模糊。我<strong><em>试图</em></strong>得到的是:</p>

<p> <a href="https://www.evernote.com/shard/s111/sh/645d307f-c597-4dfa-890f-9404ed297e71/fd738fdf15cd956fcfa917e4311bfd1b" rel="noreferrer noopener nofollow">https://www.evernote.com/shard/s111/sh/645d307f-c597-4dfa-890f-9404ed297e71/fd738fdf15cd956fcfa917e4311bfd1b</a> </p>

<p>我<strong><em>实际上</em></strong>得到的是:</p>

<p> <a href="https://www.evernote.com/shard/s111/sh/27440e85-2181-49e1-89e0-4b57e0ce3783/e6e2abae0edfb705e915b03e1b37e008" rel="noreferrer noopener nofollow">https://www.evernote.com/shard/s111/sh/27440e85-2181-49e1-89e0-4b57e0ce3783/e6e2abae0edfb705e915b03e1b37e008</a> </p>

<p>这是我用来创建模糊并将其附加到选择器的代码:</p>

<pre><code>UIBlurEffect *blurEffect = ;
UIVisualEffectView *blurEffectView = [ initWithEffect:blurEffect];
;
;
;
</code></pre>

<p>请注意,即使调用了 <code>sendSubviewToBack</code>,最终也会将模糊 <strong><em>置于选项轮的前面</em></strong>。如果我在 ScrollView 时仔细观察,我可以看到选项在模糊<em>后面</em>移动。</p>

<p>如何在背景中正确获得模糊效果并在顶部设置选项轮?</p></p>
                                    <br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
                                            <p><p>由于您不知道 UIPickerView 的确切 View 层次结构,我只是建议将您的 pickerView <code>clearColor</code> 作为 backgroundColor 并将选择器 View 作为您的 blurEffectView 的 subview 。这是正确的做法。</p></p>
                                   
                                                <p style="font-size: 20px;">关于ios - 模糊 UIPickerView 背景,我们在Stack Overflow上找到一个类似的问题:
                                                        <a href="https://stackoverflow.com/questions/28754716/" rel="noreferrer noopener nofollow" style="color: red;">
                                                                https://stackoverflow.com/questions/28754716/
                                                        </a>
                                                </p>
                                       
页: [1]
查看完整版本: ios - 模糊 UIPickerView 背景