显示视图时 iOS 调暗背景 [英] iOS Dim background when a view is shown

查看:23
本文介绍了显示视图时 iOS 调暗背景的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的主视图中,我做了一些手势操作,导致显示一些新视图.此时我想将整个背景调暗(除了这个新视图)作为一个很好的 UI 实践.在 HTML、Javascript 中,它看起来像这样 - 如何在 iOS 中获得同样的效果?

In my main view, I do some gesture action causing some new view to be shown. At this time I want to dim the entire background (except this new view) as a good UI practice. In HTML, Javascript it looks like so - How do I get this same effect in iOS ?

推荐答案

在背景上放置一个 UIView,将其背景设置为 [UIColor blackColor] 并将其不透明度设置为 0.6.然后将该 UIView 添加到父视图中.

Lay a UIView over the background, set its background to [UIColor blackColor] and set its opacity to like 0.6. Then add that UIView to the parent view.

这会使背景变暗并拦截对背景控件的任何点击.

This'll dim out the background AND intercept any taps to background controls.

这篇关于显示视图时 iOS 调暗背景的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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