iOS Learning Note 20: Remove UITableView extra blank line split line

Source: Internet
Author: User

First, the problem description

In the study and development often encounter the following problems, UITableView UITableViewCell little or no time, but UITableView have a lot of blank line split line. Such as:

How do I get rid of UITableView extra blank line split line?

Second, the problem analysis

Method One: Hide the UITableViewCell from the split line, and then customize the split line to UITableViewCell. There are many ways to customize a split line, and you can find it yourself.

Method Two: very simple, modify the Tablefooterview. Create a UIView with a frame of Cgrectzero , and assign a value to Tablefooterview.

Second, problem solving1. Custom Split Line

Lists one of the ways to customize a split line.

Step One: Global Settings uitableviewcell system comes with a split line "hide", this "hide" simply sets the split line color to transparent. This is done to keep the custom split line frame and the system's own split line. If you don't want to, you can really hide.

 1 -(void  ) viewdidload  2  { //  Set the style of the split line  4  self.tableViewCategory.separatorStyle = Uitableviewcellseparatorstylesingleline;  5  self.tableViewCategory.separatorColor = [ Uicolor Clearcolor];  6  self.tableViewList.separatorStyle = Uitableviewcellseparatorstylesingleline;  7  self.tableViewList.separatorColor = [Uicolor Clearcolor];  8 } 

Step Two: in UITableViewCell

1 //self-plotting split line2- (void) DrawRect: (cgrect) Rect3 {4     //gets the split line that comes with the cell system, and gets the split line object to keep the custom split line frame and the system's own split line. If you do not want the same, you can ignore. 5UIView *separatorview = [Self Valueforkey:@"_separatorview"];6NSLog (@"%@", Nsstringfromcgrect (Separatorview.frame));7NSLog (@"%@", Nsstringfromcgrect (rect));8 [Super Drawrect:rect];9Cgcontextref context =Uigraphicsgetcurrentcontext ();Ten Cgcontextsetstrokecolorwithcolor (context, [Uicolor colorwithred:232/255.0 green:232/255.0 blue:232/255.0 Alpha : 1]. Cgcolor); One     //cgcontextstrokerect (context, CGRectMake (0, Rect.size.height-1, rect.size.width, 1)); A cgcontextstrokerect (context, separatorview.frame); -}

Effect:

2. Modify tablefooterview
1  Self.tableView.tableFooterView = [[UIView alloc] Initwithframe:cgrectzero];

Effect:

iOS Learning Note 20: Remove UITableView extra blank line split line

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.