I’m coding a custom TableViewCell and I need to set a background image for each one (actually same background image on all cells) and I’ll add some labels for different type of texts (different in font, size, color, etc…) and a left image hosted on a web server. I’ve read a tutorial on how to make the TableViewCell using IB and add it to cellForRowAtIndePath method. It worked but the image size and texts in labels are not showing like I was seeing them in IB, not wysiwyg at all lol
So, I need your help to choose the proper way to customize these cells, should I go for the IB way or programming tips are better?
Thx in advance for helping,
Stephane
I am guessing that the size of your images is going beyond the expected size of the
imageViewproperty for the left image. That usually pushes around all the other UI elements. You can avoid that by settingimageView.layer.masksToBoundsof your cell toYES.In general, for the problem you describe, I would recommend doing everything programmatically. You will have the opportunity for abstraction and include your program logic more economically.
To keep your
cellForRowAtIndexPathmethod reasonably short, you can call your ownformatCellAtIndexPathmethod and keep the formatting logic neatly separated from the content.