Alberto93
Alberto93

Reputation: 117

How to remove padding from a UIView?

I am new to iOS development and I couldn't find an answer online for this. So I have a UIView and I have a UITableView within that view. But for some odd reason the table view doesn't extend the full width of the parent UIView.

The red color is the UIView.

The green color is the UITableView.

enter image description here

Here are the constraints for the TableView

enter image description here

Here are the constraints for the UIView

enter image description here

How can I get the table view to have the full width of the device/the UIView such that the only red visible is in the bottom and not on the sides as its currently shown in the picture? (The horrible colors are just for visual explanation. Not going to keep them lol)

Upvotes: 0

Views: 1924

Answers (2)

Mo Abdul-Hameed
Mo Abdul-Hameed

Reputation: 6110

In your Storyboard:

  1. Remove your current leading and trailing constraints of your table view, and leave your other constraints as they are.
  2. From the bottom right of UI Builder, click on Add New Constraint pin, and uncheck constrain to margins then set your leading and trailing constraints to 0 and add them.

enter image description here

Upvotes: 2

user4850802
user4850802

Reputation:

Remove constrain to margins as already suggested. Next select the left, top, right, and bottom bar, and make sure that the left, top and right margin settings are set to 0 and select a value for the bottom margin. This will force the view to the edges of the superview.[1]: https://i.sstatic.net/dNBfm.png

Upvotes: 0

Related Questions