开发者

how to reduce/remove the left/right hand margin in a grouped UITableView?

开发者 https://www.devze.com 2023-04-03 16:03 出处:网络
How to reduce/remove the left/right hand margin in a grouped UITableView? Is there a way to do this without defining a custom view, i.e. using a UITableViewController directly?

How to reduce/remove the left/right hand margin in a grouped UITableView?

Is there a way to do this without defining a custom view, i.e. using a UITableViewController directly?

I'm NOT asking here about the space between cells, it the space to the left & right of cells you see.

EDIT 1: Can I clarify:

  • already have a custom UITableViewCell ("@interface AppointCell : UITableViewCell") in my solution
  • I think the area to the left and right of these custom UITableViewCell's however are not directly from the cell itse开发者_Python百科lf - I say this only as when I put a border around the cell (via it's layer) I can see this - so therefore it seems like the space is from the UITableView itself (not the cells)
  • should point out again I'm using GROUPED mode for the table view


Sure; just adjust the frame of the UITableView so it's a little wider than its superview and a little to the left (in the negative X direction, in other words) of its left boundary.


I believe you have to create a custom cell view for your table which has padding on the left and right side.


You can also make the cell itself a bit wider. Add this method to your UITableViewCell subclass.

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

I Believe the offset should be 9 points. As a side note: If you set a custom background for the cell, you may also have to set it's selectedBackground.


You can use custom cell by extending UITableViewCell. I recommend you to take a look at http://www.e-string.com/content/custom-uitableviewcells-interface-builder

0

精彩评论

暂无评论...
验证码 换一张
取 消