Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1746,7 +1746,13 @@ - (NSString *)componentViewName_DO_NOT_USE_THIS_IS_BROKEN

- (BOOL)styleNeedsSwiftUIContainer
{
if (!_props->filter.empty()) {
if (_props->filter.empty()) {
return NO;
}

// A filter must not affect layout, but UIHostingController insets its content by the safe area.
// To disable the insets we use `safeAreaRegions` which is only available in iOS 16.4 and tvOS 16.4.
if (@available(iOS 16.4, tvOS 16.4, *)) {
for (const auto &primitive : _props->filter) {
if (primitive.type == FilterType::Blur || primitive.type == FilterType::Grayscale ||
primitive.type == FilterType::DropShadow || primitive.type == FilterType::Saturate ||
Expand All @@ -1755,6 +1761,7 @@ - (BOOL)styleNeedsSwiftUIContainer
}
}
}

return NO;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,13 @@ import UIKit

@objc public override init() {
super.init()
hostingController = UIHostingController(rootView: SwiftUIContainerView(viewModel: containerViewModel))
guard let view = hostingController?.view else {
let controller = UIHostingController(rootView: SwiftUIContainerView(viewModel: containerViewModel))
if #available(iOS 16.4, tvOS 16.4, *) {
// Disable implicit safe area insets or else the view is shifted by the safe area insets
controller.safeAreaRegions = []
}
hostingController = controller
guard let view = controller.view else {
return
}
view.backgroundColor = .clear
Expand Down
Loading