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?
UITableViewHeaderFooterView
rather than aUITableViewCell
? Apple talks about this issue with header views in this video starting at 8 minutes in: developer.apple.com/videos/play/fall2017/201 – Toft