The length of the UITableView split line is controlled by the length of the uitableview

Source: Internet
Author: User

The length of the UITableView split line is controlled by the length of the uitableview

The default cell split line of UITableView is not full on the left, but full on the right. This display is ugly. I need to make the left and right sides of it not full, the distance is 20 pixels

 

// code1    if ([self.tableView respondsToSelector:@selector(setSeparatorInset:)]) {        [self.tableView setSeparatorInset:UIEdgeInsetsMake(0, 20, 0, 20)];    }// code2     if ([self.tableView respondsToSelector:@selector(setLayoutMargins:)]) {        [self.tableView setLayoutMargins:UIEdgeInsetsMake(0, 20, 0, 20)];    }

 

Add a proxy method for UITableView:

- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath{    if ([cell respondsToSelector:@selector(setSeparatorInset:)])    {        [cell setSeparatorInset:UIEdgeInsetsMake(0, 15, 0, 15)];    }    if ([cell respondsToSelector:@selector(setLayoutMargins:)])    {        [cell setLayoutMargins:UIEdgeInsetsMake(0, 15, 0, 15)];    }}

 

Ode1 code:
Customize the frame of the cell split line

Code at code2:
-LayoutMargins returns a set of insets from the edge of the view's bounds that denote a default spacing for laying out content.
If preservesSuperviewLayoutMargins is YES, margins cascade down the view tree, adjusting for geometry offsets, so that setting the left value of layoutMargins on a superview will affect the left value of layoutMargins for subviews positioned close to the left edge of their superview's bounds
If your view subclass uses layoutMargins in its layout or drawing, override-layoutMarginsDidChange in order to refresh your view if the margins change.

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.