Deepak Sharma
Deepak Sharma

Reputation: 6537

UITableViewCell contentView inset on iPhone X

Any UITableViewCell created on iPhone X has a 44 points inset for content view. This means width of contentView of UITableViewCell is by default 44pts less than the cell width. I do not need to have this behavior. How do I get contentView width same as cell width (or like it is there on other iPhone models)?

Update: I solved the problem by setting tableView.insetsContentViewsToSafeArea = NO. Now working on same issue for other elements such as UINavigationBar items. Unable to find an equivalent was for UIBarButtonItem for navigation bar. Any insight is appreciated.

Upvotes: 2

Views: 1748

Answers (2)

Amila
Amila

Reputation: 284

In your table view set insetsContentViewsToSafeArea to false.

tableview.insetsContentViewsToSafeArea = false

Upvotes: 0

FLK
FLK

Reputation: 98

Maybe you could use additionalSafeAreaInsets on your view controller, it's there to reduce the actual usable space but with negative Insets it should do the opposite.

https://developer.apple.com/documentation/uikit/uiviewcontroller/2902284-additionalsafeareainsets

Upvotes: 1

Related Questions