I have a UITableView
and the first row is used as a sort of header cell with a full bleed background image and other elements. For this cell I do NOT want to use the SafeArea
and I want the UIView
to expand all the way to the edge of the screen. Currently I get this:
I have tried to set this manually for the cell:
if (@available(iOS 11.0, *)) {
headerCell.insetsLayoutMarginsFromSafeArea = NO;
headerCell.layoutMargins = UIEdgeInsetsMake(10, 0, 10, 0);
UIEdgeInsets i = headerCell.layoutMargins;
NSLog(@"Left: %f", i.left);
}
Sadly this doesn't work.
Here is a mockup of what it should look like, with the first cell contents NOT being affected by the safe area:
Is there any way to do what I am wanting just for the first cell?
(In tvOS, the safe area reflects the area not covered by the screen's bezel.) You obtain the safe area for a view by applying the insets in this property to the view's bounds rectangle. If the view is not currently installed in a view hierarchy, or is not yet visible onscreen, the edge insets in this property are 0 .
On landscape images, the default safe area is approximately 1750 x 1035 pixels, and on portrait images the default safe area is approximately 874 x 1340 pixels.
I found that I needed to uncheck the Content View Insets To Safe Area
checkbox that is on the UITableView.
Doing this fixed the issue!
Marking the "Content insets" under Size Inspector to "Never" worked for me.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With