Search code examples
uitableviewxcode10ios12swift4.2

iOS 12 - Xcode 10 - SWIFT 4.2 - UITableView extra space missing from left and right


There is a change in UITableView layout after upgrading to iOS 12 from iOS 11. Please find below images for reference:

iOS 11 look and feel for UITableview:

enter image description here

iOS 12 look and feel for UITableview:

enter image description here

On comparing two above images, there is a absence of extra space from left and right of UITableView in iOS 12.

I want to have same look and feel as iOS 11 for UITableView in iOS 12 as well.

Need some suggestion for the mentioned issue. I am using Xcode 10 and upgraded code to SWIFT 4.2.


Solution

  • I am able to figure out the root cause and a solution for the issue.

    There is a property for UITableView - "cellLayoutMarginsFollowReadableWidth" which is "true" by default in iOS 11. In iOS 12 the default value for the property is "false"

    Setting the property value to "true" solved the issue.

    Please find the below code as reference :

    tableView.cellLayoutMarginsFollowReadableWidth = true