顶部 UIView 的透明度不起作用 [英] Transparency for top UIView not working

查看:40
本文介绍了顶部 UIView 的透明度不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

UINavigationController 中,我有一个 UITableView.我使用设置按钮来允许用户更改某些表格设置.

当点击设置按钮时,我将一个新视图推送到导航堆栈上.

这个新视图具有以下视图结构

-> UIView1 411 x 320 px (backgroundColor 应该是透明的)!!!!

-->> UIView2 270 x 300 px (backgroundColor grey)

--->>> 屏幕元素

我的问题是我希望 UIView1 是透明的,以便后面的信息仍然可见.我所有的尝试,例如

  • 设置背景颜色为透明

  • 改变 alpha 值

  • 移除不透明指示器

到目前为止都失败了.

有什么线索吗?最欣赏!

解决方案

UINavigationController 并非旨在允许埋藏"的视图控制器仍显示在当前可见的视图控制器下.(iOS 框架实际上可以卸载导航堆栈上不是当前顶部项的视图控制器的视图!)

因此,如果您尝试这样做,它就是行不通的,或者您会遇到问题.(iPhone 上的模态视图控制器也是如此——即使你将背景设为透明,你推到上面的视图也会消失.)

如果您确实希望旧 UI 在下方仍然可见,请考虑将新的整个 UI 呈现为放置在当前视图上的 UIView(即执行 [existingView addSubview:myNewView])..>

In a UINavigationController I have a UITableView. I use a settings-button to allow users changing some table settings.

When the settings-button is tapped I push a new view onto the navigation stack.

This new view has the following view structure

-> UIView1 411 x 320 px (backgroundColor supposed to be transparent) !!!!

-->> UIView2 270 x 300 px (backgroundColor grey)

--->>> Screen elements

My problem is that I want UIView1 to be transparent so that the information behind is still visible. All my attempts, such as

  • setting the bg color to transparent

  • changing the alpha value

  • removing the Opaque indicator

have failed so far.

Any clues? most appreciated!

解决方案

UINavigationController is not designed to allow "buried" view controllers to still be showing under the current visible view controller. (The iOS framework can actually unload the views of view controllers on the nav stack that aren't the current top item!)

So if you try to do it, it just won't work, or you'll have problems. (Same goes for modal view controllers on the iPhone -- even if you make the background transparent, the view you're pushing on top of will disappear.)

If you really want the old UI to still be visible underneath, consider presenting your new entire UI as a UIView placed over the current view (i.e. do [existingView addSubview:myNewView]).

这篇关于顶部 UIView 的透明度不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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