縮短 UITableViewCell 的寬度


改變 UITableViewCell 高度很容易,因為 UITableViewDelegate 就可以搞定了。
但是要改變 UITableViewCell 的 width 的話就有幾種作法:
  1. Change UITableView frame
  2. Subclass UITableViewCell + Override setFrame:
  3. Make normal UITableViewCell.backgroundColor = [UIColor clearColor], then customize yourself.
在這邊我覺得最漂亮的就是 2.) 了。
Here is your snippet:

- (void)setFrame:(CGRect)frame 
{
    frame.origin.x += inset;
    frame.size.width -= 2 * inset;
    [super setFrame:frame];

留言

熱門文章