UITableViewCell with image on the right?

前端 未结 11 1079
南方客
南方客 2020-12-13 05:48

Is there a way to set the UITableViewCell.image to display on the right hand side of the cell instead of the left? Or will I need to add a separate UIImageView on the right

11条回答
  •  遥遥无期
    2020-12-13 06:31

    For simple cases you can do this:

    cell.contentView.transform = CGAffineTransformMakeScale(-1,1);
    cell.imageView.transform = CGAffineTransformMakeScale(-1,1);
    cell.textLabel.transform = CGAffineTransformMakeScale(-1,1);
    cell.textLabel.textAlignment = NSTextAlignmentRight; // optional
    

    This will flip (mirror) the content view placing any imageView on the right. Note that you have to flip the imageView and any text labels also otherwise they themselves would be mirrored! This solution preserves the accessory view on the right.

提交回复
热议问题