QQ Space HD (6)-Implement a custom tab transition effect

Source: Internet
Author: User

Djtabbarbutton.m

#import "DJTabbarButton.h"@implementationDjtabbarbutton-(Instancetype) initWithFrame: (CGRect) Frame {if(self =[Super Initwithframe:frame]) {[Self setbackgroundimage:[uiimage imagenamed:@"TABBAR_SEPARATE_SELECTED_BG"] forstate:uicontrolstatedisabled]; Self.imageView.contentMode=Uiviewcontentmodecenter; /*set the picture to not be modified when the button is unavailable or in a highlighted state*/self.adjustsimagewhendisabled=NO; Self.adjustsimagewhenhighlighted=NO;//Self.backgroundcolor = [Uicolor greencolor];    }    returnSelf ;}- (void) layoutsubviews {[Super layoutsubviews]; if(Djlandscape) {//Horizontal Screen                /*ImageView*/self.imageview.x=0; Self.imageview.y=0; Self.imageView.width= Self.width *0.4; Self.imageView.height=Self.height; /*Titlelabel*/Self.titleLabel.hidden=NO; Self.titlelabel.x=Self.imageView.width; Self.titlelabel.y=0; Self.titleLabel.width= Self.width-Self.imageView.width; Self.titleLabel.height=Self.height; } Else{//Vertical Screen            /*ImageView*/Self.imageView.frame=Self.bounds; /*Titlelabel*/Self.titleLabel.hidden=YES; }}/*Set button no highlighting status*/- (void) sethighlighted: (BOOL) highlighted {}@end

Djhomeviewcontroller.m

//Adding a child controller- (void) Setupchildviewcontrollers { for(inti =0; I <6; i++) {Uiviewcontroller*CHILDVC =[[Uiviewcontroller alloc] init]; ChildVC.view.backgroundColor=Djrandomcolor;    [Self ADDCHILDVIEWCONTROLLER:CHILDVC]; }}- (void) Replacecurrentshowingcontroller: (djtabbarindex) Index {//removes the view of the currently displayed sub-controller from the interface[Self.showingChildVc.view Removefromsuperview]; Uiviewcontroller*NEWSHOWINGVC; Switch(index) { CaseDjtabbarindexallstatus://All NewsNEWSHOWINGVC = self.childviewcontrollers[0];  Break;  CaseDjtabbarindexwithme://related to meNEWSHOWINGVC = self.childviewcontrollers[1];  Break;  CaseDjtabbarindexphotowall://Photo QiangNEWSHOWINGVC = self.childviewcontrollers[2];  Break;  CaseDjtabbarindexphotoframe://Electronic Photo FrameNEWSHOWINGVC = self.childviewcontrollers[3];  Break;  CaseDjtabbarindexfriend://FriendsNEWSHOWINGVC = self.childviewcontrollers[4];  Break;  CaseDjtabbarindexmore://moreNEWSHOWINGVC = self.childviewcontrollers[5];  Break; } newshowingvc.view.x=Self.menuView.width; Newshowingvc.view.y=0; NewShowingVc.view.width= Self.view.width-Self.menuView.width; NewShowingVc.view.height=Self.view.height;    [Self.view AddSubview:newShowingVc.view]; SELF.SHOWINGCHILDVC=NEWSHOWINGVC; }- (void) Updatesubviewframeinlandscape {/*Menuview*/Self.menuView.width=DJMENUVIEWLW; Self.menuView.height=DJSCREENLH; self.menuview.x=0; Self.menuview.y=0; /*SHOWINGCHILDVC*/self.showingchildvc.view.x=Self.menuView.width; Self.showingchildvc.view.y=0; Self.showingChildVc.view.width= DJSCREENLW-Self.menuView.width; Self.showingChildVc.view.height=DJSCREENLH; }- (void) updatesubviewsviewframeinportrait {/*Menuview*/Self.menuView.width=DJMENUVIEWPW; Self.menuView.height=djscrrenph; self.menuview.x=0; Self.menuview.y=0; /*SHOWINGCHILDVC*/self.showingchildvc.view.x=Self.menuView.width; Self.showingchildvc.view.y=0; Self.showingChildVc.view.width= DJSCREENPW-Self.menuView.width; Self.showingChildVc.view.height=djscrrenph; }//This method is called when the orientation of the screen changes- (void) Willrotatetointerfaceorientation: (uiinterfaceorientation) tointerfaceorientation Duration: (NSTimeInterval) Duration {if(Uiinterfaceorientationislandscape (tointerfaceorientation)) {//Horizontal Screen[self updatesubviewframeinlandscape]; } Else{//Vertical Screen[self updatesubviewsviewframeinportrait]; }        //sets the view of the current sub-controller to not stretch    Self.showingChildVc.view.autoresizingMask = Uiviewautoresizingnone; }

Final effect:

QQ Space HD (6)-Implement a custom tab transition 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.