Misalignment in a UITableView using UITableViewCellStyleSubtitle
I have a table with many cells, all using UITableViewCellStyleSubtitle to allow me to have an icon at left with large text to the right above a small subtitle. Pretty straightforward, but my icons vary significantly in width, and as it was the text and subtitle appeared raggedy from one row to the next (farther to the left with narrow icons, farther to the right with wide ico开发者_开发百科ns).
So in Photoshop I made them all 36 pixels wide, some with cushions of transparent pixels on either side (I assume transparent pixels are more efficient, and I may want to set a background color on the cells eventually). However, the iPhone SDK seems to be stripping out that transparent padding, as the text is STILL coming out all ragged.
Do I need to add opaque pixels on either side, or is there some way to hard-code the x position of the text and subtitle so it all aligns?
Your best bet is probably to stop using stock cells and either subclass UITableViewCell
or create a couple of UILabel
s and a UIImageView
and add them to the cell's contentView. By doing this, you can easily hard-code the x position of the labels.
精彩评论