Search code examples
iosswiftobjective-cuitableview

Is is legal to change the position of the frame of the contentView in a UITableViewCell or should I use another container view?


I am making my own custom swipeable cells where user can swipe a cell to show options. Currently all my subviews are added to the contentView of the cell. And I have added my options to the backgroundView of the cell.

enter image description here

  1. Is it okay for me to add my custom content to the backgroundView?

  2. Is it okay for me to manually change the position of the frame of the contentView when doing my swipe on the cell? And then I will reset it back to its original position after it's completed. Or should I use another view as a container?


Solution

  • Is it okay for me to add my custom content to the backgroundView?

    No. The backgroundView should be limited to a simple view whose basic properties, such as its backgroundColor, you configure. It would be even better, nowadays, to use the cell's background configuration instead.

    Is it okay for me to manually change the position of the frame of the contentView when doing my swipe on the cell?

    No. Your content should be inside a view inside a scroll view (or other "slideable" view) inside the content view. Don't touch the content view itself.