iOS development Project-49 "Discovery" interface complete

Source: Internet
Author: User

iOS development Project-49 "Discovery" interface complete

A simple explanation

Finished effect:-----target Effect

Places to be perfected:

(1) Subheadings and headings appear on the same line.

Modify Style: Uitableviewcellstylesubtitle---"UITableViewCellStyleValue1

1 //Initialize class methods2+ (Instancetype) Cellwithtablview: (UITableView *) TableView3 {4     StaticNSString *id=@"ID";5Yycommoncell *cell=[TableView Dequeuereusablecellwithidentifier:id];6     if(cell==Nil) {7 //cell = [[Yycommoncell alloc]initwithstyle:uitableviewcellstylesubtitle reuseidentifier:id];8Cell =[[Yycommoncell alloc]initwithstyle:uitableviewcellstylevalue1 reuseidentifier:id];9     }Ten     returncell; One}

(2) Set text for title and sub-headings

Set the caption font to bold in black, and set the sub-heading to font number 12th.

1 //2 //YYCOMMONCELL.M3 4-(ID) Initwithstyle: (Uitableviewcellstyle) style Reuseidentifier: (NSString *) Reuseidentifier5 {6self=[Super Initwithstyle:style reuseidentifier:reuseidentifier];7     if(self) {8         //set text for title and sub-headings9Self.textlabel.font=[uifont boldsystemfontofsize: the];TenSelf.detailtextlabel.font=[uifont systemfontofsize: A]; One     } A     returnSelf ; -}

The effect after adjustment:

(3) The text of the sub-caption is displayed immediately after the caption, rather than right-aligned.

1 //2 //YYCOMMONCELL.M3 4 #pragmamark-adjusting the position of a child control5-(void) Layoutsubviews6 {7 [Super Layoutsubviews];8     //adjust the X-value of a sub-caption9Self.detailtextlabel.x=cgrectgetmaxx (Self.textLabel.frame) +Ten;Ten}

(4) Set the background color of the tableview and adjust the spacing between the groups.

Sets the height of the head and tail of each group

Implementation code:

1- (void) Viewdidload2 {3 [Super Viewdidload];4     5     //Create and add a search box6     //Add a search box7Yysearchbar *searchbar=[Yysearchbar Searchbar];8Searchbar.frame=cgrectmake (0, -, -, *);9self.navigationitem.titleview=Searchbar;Ten      One     //setting the properties of a TableView A     //setting the global background color -Self.tableview.backgroundcolor=YYGLOBALBG; -self.tableview.sectionfooterheight=0; theself.tableview.sectionheaderheight=Yystatuscellmargin; -      -  -     //Initializing model data + [self setupgroups]; -}

The display effect at this time:

(5) The distance of the first cell.

The first approach: in a custom cell, let the Y value of each cell move a distance online.

1 -(void) Setframe: (cgrect) frame2{3     frame.origin.y-=  - ; 4     [Super Setframe:frame]; 5 }

Print view TableView in the controller frame

1- (void) Viewdidload2 {3 [Super Viewdidload];4     5     //Create and add a search box6     //Add a search box7Yysearchbar *searchbar=[Yysearchbar Searchbar];8Searchbar.frame=cgrectmake (0, -, -, *);9self.navigationitem.titleview=Searchbar;Ten      One     //setting the properties of a TableView A     //setting the global background color -Self.tableview.backgroundcolor=YYGLOBALBG; -self.tableview.sectionfooterheight=0; theself.tableview.sectionheaderheight=Yystatuscellmargin; -      -     //Initializing model data - [self setupgroups]; +      -Yylog (@"viewdidload---%@", Nsstringfromuiedgeinsets (Self.tableView.contentInset)); + } A  at-(void) Viewdidappear: (BOOL) Animated - { - [Super viewdidappear:animated]; -Yylog (@"viewdidappear---%@", Nsstringfromuiedgeinsets (Self.tableView.contentInset)); -}

The navigation bar above and the toolbar below will always have a distance of 64 and 49.

View the location of the first cell

-(void) Setframe: (cgrect) frame{//    frame.origin.y-=30;    Yylog (@ "%f", self.y);    [Super Setframe:frame];}

Print view

The cell's original height is 35.

The second approach

1- (void) Viewdidload2 {3 [Super Viewdidload];4     5     //Create and add a search box6     //Add a search box7Yysearchbar *searchbar=[Yysearchbar Searchbar];8Searchbar.frame=cgrectmake (0, -, -, *);9self.navigationitem.titleview=Searchbar;Ten      One     //setting the properties of a TableView A     //setting the global background color -Self.tableview.backgroundcolor=YYGLOBALBG; -self.tableview.sectionfooterheight=0; theself.tableview.sectionheaderheight=Yystatuscellmargin; -      -     //Initializing model data - [self setupgroups]; +      -Yylog (@"viewdidload---%@", Nsstringfromuiedgeinsets (Self.tableView.contentInset)); +    Self.tableview.contentinset=uiedgeinsetsmake (yystatuscellmargin-, 0, 0, 0 ); A}

Final effect:

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.