UITableViewCell inside the separator set

Source: Internet
Author: User

When the cell is recently displayed, the left side has a 15-pixel offset, and the following method//1 is checked. No use
[Self.tableview Setseparatorinset:uiedgeinsetszero];

2. The effect is not obvious, and the split line cannot be displayed completely from the first pixel
1- (void) TableView: (UITableView *) TableView Willdisplaycell: (UITableViewCell *) cell Forrowatindexpath: (Nsindexpath *) Indexpath {2     if([Self.tableview respondstoselector: @selector (setseparatorinset:)])3     {4 [Self.tableview Setseparatorinset:uiedgeinsetszero];5     }6     if([Self.tableview respondstoselector: @selector (setlayoutmargins:)])7     {8 [Self.tableview Setlayoutmargins:uiedgeinsetszero];9     }Ten}

3. Rewrite the DrawRect method, has the effect, the color setting is convenient, but the operation cell, will increase the mobile phone burden
1- (void) DrawRect: (cgrect) rect {2Cgcontextref context =Uigraphicsgetcurrentcontext ();3 Cgcontextsetfillcolorwithcolor (context, [Uicolor Clearcolor]. Cgcolor);4 cgcontextfillrect (context, rect);5    6     //on split Line7 Cgcontextsetstrokecolorwithcolor (Context,[uicolor Whitecolor]. Cgcolor);8Cgcontextstrokerect (Context,cgrectmake (0,0, Rect.size.width,1));9    Ten     //Lower Split Line One Cgcontextsetstrokecolorwithcolor (Context,[uicolor Whitecolor]. Cgcolor); ACgcontextstrokerect (Context,cgrectmake (0, rect.size.height-1, Rect.size.width,1)); -}

4. Customize the cell, hide the cell's separator color, and then add a 1-pixel view to the cell's separator position, set the view color, that is, use the view as a split line, the display works perfectly

UITableViewCell inside the separator set

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.