首页 > 解决方案 > 将 Xib 中的视图添加到透明视图中,为什么它显示得更暗?

问题描述

这是代码

self.viewD = DayViewCalendar(frame: CGRect(x: 0, y: 0, width: 
self.containerView.frame.size.width, height: 
self.containerView.frame.size.height))
    

这是不透明的,是错误的,背景是清晰的。

self.viewD.isOpaque = false
self.viewD.backgroundColor = UIColor.clear
self.containerView.addSubview(self.viewD)

也适用于容器

container.isOpaque = false
container.backgroundColor = UIColor.clear

输出 :

在此图像下方,图像的下一个文本部分显示稍暗

如果我不添加 ViewD,则容器是透明的,如图所示

没有视图的图像D

问题

为什么 Tow Transparent UIViews 不透明,它显示得稍暗

请建议我在哪里做错了

标签: iosswiftuiviewalpha-transparency

解决方案


从长远来看,这里有一些可以帮助你的东西。

https://developer.apple.com/library/content/documentation/DeveloperTools/Conceptual/debugging_with_xcode/chapters/special_debugging_workflows.html

这可以帮助您调试视图组件并告诉您究竟是哪个视图导致了 UI 中的灰色区域。

希望这可以帮助。快乐调试


推荐阅读