iOS开发-修改UITableViewCell中image和title的位置和大小

最近在开发中遇到需要Cell中imageView和textLable位置和大小的情况,设计希望得到的结果如下图所示:

而TableViewCell默认样式,image是靠紧左边的,并且image和title之间的间隙较小

为实现设计中的效果,我们需要继承UITableViewCell,对cell.imageView.frame、cell.textLable.frame进行设置,控制它们大小和位置。

- (void)layoutSubviews {

    [superlayoutSubviews];

    self.imageView.frame =CGRectMake(0,0,44,44);

    self.imageView.contentMode =UIViewContentModeScaleAspectFit;

    

    CGRect tmpFrame = self.textLabel.frame;

    tmpFrame.origin.x = 46;

    self.textLabel.frame = tmpFrame;

 

}

原文地址:https://www.cnblogs.com/feiling/p/4789184.html