简体   繁体   English

iOS 13 添加带有阴影的 UIWindow

[英]iOS 13 Adding a UIWindow with shadow

I would like to add a UIWindow with shadow and corners in iOS 13. My UIWindow looks like this:我想在 iOS 13 中添加一个带有阴影和角落的 UIWindow。我的 UIWindow 如下所示:

- UIWindow
  - backgroundView
  - containerView
    - topContainerView(containers for avatar and nickname)
    - replyView
    - ......

Currently, I add corners with UIBezierPath in my containerView, and add shadow in my backgroundView.目前,我在 containerView 中使用 UIBezierPath 添加角,并在 backgroundView 中添加阴影。 It works perfectly under iOS 12. But in iOS 13, it does not work.它在 iOS 12 下完美运行。但在 iOS 13 中,它不起作用。

Expected :预期的 :

预期图像

Currently:目前:

当前图像

Any suggestions and ideas would be appreciated.任何建议和想法将不胜感激。

Turns out the UIDropShadowView under iOS 13 defaults its clipsToBounds to true.原来 iOS 13 下的 UIDropShadowView 默认它的 clipsToBounds 为 true。

To fix this, manually set its clipsToBounds property to false.要解决此问题,请手动将其 clipsToBounds 属性设置为 false。

window.subviews.first?.subviews.first?.clipsToBounds = false

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM