首页 > 解决方案 > 共享扩展中的 UIHostingController 不会调整其根视图的大小

问题描述

我在共享扩展中使用了 swiftUI,使用 UIHostingController。当用户在共享扩展打开时更改设备方向时,UIHostingController rootView 不会改变它的宽度

标签: iosswift

解决方案


所以实际的问题是这个函数 func roundCorners(corners: UIRectCorner, radius: CGFloat) { let path = UIBezierPath(roundedRect: bounds, byRoundingCorners: corners, cornerRadii: CGSize(width: radius, height: radius)) let mask = CAShapeLayer() mask.path = path.cgPath layer.mask = mask }

它导致它所应用的容器永远不会改变它的宽度和高度,从而导致效果,从而使容器在将设备方向从纵向更改为陆地空间时看起来很糟糕


推荐阅读