Reputation: 5507
I have table view cells with cell image and text label and detailed label. Problem is cell image is too near to edge of cell(to the left). I want to put some space between edge and cell image. i.e. wants to move image bit away from corner. I have moved that with creating subview and putting image in that. But problem is it now overcome cell text and detailed text as well. I want to move cell text and detailed label to the right as well.
How can i do that?
For moving cell image, i am using below code:
UIImageView *imageview=[UIImageView alloc]]init];
imageView.frame=CGRectMake(10,0,40,40);
[[cell.contentView]addsubview:imageView];
But i want to move text and detailed text label as well.
Upvotes: 0
Views: 493
Reputation: 42574
You don't need that image view to move the image.
Subclass UITableViewCell
and add the following method to the subclass:
- (void)layoutSubviews {
[super layoutSubviews];
CGRect imageFrame = self.imageView.frame;
imageFrame.origin.x += 10;
self.imageView.frame = imageFrame;
CGRect textFrame = self.textLabel.frame;
textFrame.origin.x += 10;
self.textLabel.frame = textFrame;
CGRect detailTextFrame = self.detailTextLabel.frame;
detailTextFrame.origin.x += 10;
self.detailTextLabel.frame = detailTextFrame;
}
Change 10
to whatever you see fit.
Upvotes: 1