Search code examples
iosuitableviewswift2widthcell

How do i set width to Custom UITableViewCell


I want to set the width of custom UITableViewCell to 80% of the screen width but I know the size of the cell can be manipulated using "layoutSubviews()" methods but I don't know how.

Please help me.


Solution

  • Drag and drop UIView to your content view of cell (i.e. in cell). Adjust it's height and width according to your need as you said 80% (so give padding like wise). The set top,bottom,leading and trailing constraints if you are using autolayout.

    You can set your contentview's background color as clear color and cell's background as clear color as well or desired color you want. Likewise you can set your tableview's background color also!