源码介绍:这是一个仿照暴风影音的demo,因为项目需要,所以顺便改进了一点,功能包括侧滑,滚动导航栏,tableView,collectionView高度自定义,希望能帮助需要代码的朋友。源码效果:源码片段:-(void)viewDidLoad{self.view.backgroundColor=[UIColorwhiteColor];UIView*statusBarView=[[UIImageViewalloc]initWithFrame:CGRectMake(0.f,0.f,self.view.frame.size.width,0.f)];if(isIos7>=7&&__IPHONE_OS_VERSION_MAX_ALLOWED>__IPHONE_6_1){statusBarView.frame=CGRectMake(statusBarView.frame.origin.x,statusBarView.frame.origin.y,statusBarView.frame.size.width,20.f);statusBarView.backgroundColor=[UIColorclearColor];((UIImageView*)statusBarView).backgroundColor=RGBA(33.f,125.f,194.f,1);[self.viewaddSubview:statusBarView];}/导航bar_navView=[[UIImageViewalloc]initWithFrame:CGRectMake(0.f,StatusbarSize,self.view.frame.size.width,50.f)];((UIImageView*)_navView).backgroundColor=RGBA(33.f,125.f,194.f,1);[self.viewinsertSubview:_navViewbelowSubview:statusBarView];_navView.userInteractionEnabled=YES;//导航栏图标[selfsetNavbtn];//滚动导航栏_topNaviV=[[UIViewalloc]initWithFrame:CGRectMake(0,_navView.frame.size.height+_navView.frame.origin.y,self.view.frame.size.width,MENU_HEIGHT)];_topNaviV.backgroundColor=RGBA(33.f,125.f,194.f,1);[self.viewaddSubview:_topNaviV];//滚动页面_scrollV=[[UIScrollViewalloc]initWithFrame:CGRectMake(0,_topNaviV.frame.origin.y+_topNaviV.frame.size.height,self.view.frame.size.width,self.view.frame.size.height-_topNaviV.frame.origin.y-_topNaviV.frame.size.height)];_scrollV.tag=_scrollVTag;[_scrollVsetPagingEnabled:YES];[_scrollVsetShowsHorizo??ntalScrollIndicator:NO];[self.viewinsertSubview:_scrollVbelowSubview:_navView];_scrollV.delegate=self;[_scrollV.panGestureRecognizeraddTarget:selfaction:@selector(scrollHandlePan:)];//选择弹出的view_selectTabV=[[UIViewalloc](0,_scrollV.frame.origin.y-_scrollV.frame.size.height,_scrollV.frame.size.width,_scrollV.frame.size.height)];[_selectTabVsetBackgroundColor:RGBA(255.f,209.f,56.f,1)];[_selectTabVsetHidden:YES];[self.viewinsertSubview:_selectTabVbelowSubview:_navView];//创建滚动条菜单[selfcreateScrollBtns];}//创建主导航菜单-(void)setNavbtn{UIButton*MenuBtn=[UIButtonbuttonWithType:UIButtonTypeCustom];[MenuBtnsetFrame:CGRectMake(15,8,20,20)];[MenuBtnsetBackgroundImage:[UIImageimageNamed:@"icon_list"]forState:UIControlStateNormal];[MenuBtnaddTarget:selfaction:@selector(leftAction:)forControlEvents:UIControlEventTouchUpInside];MenuBtn.showsTouchWhenHighlighted=YES;[_navViewaddSubview];forMenuBtn(inti=0;i<4;i++){UIButton*NavBtn=[UIButtonbuttonWithType:UIButtonTypeCustom];[NavBtnsetFrame:CGRectMake(170+i*40,8,20,20)];NSString*NavBtn_backimg=[NSStringstringWithFormat:@”slide_menu_%d@2x",i+1];[NavBtnsetBackgroundImage:[UIImageimageNamed:NavBtn_backimg]forState:UIControlStateNormal];[NavBtnaddTarget:selfaction:@selector(NavbtnAction:)forControlEvents:UIControlEventTouchUpInside];NavBtn.tag=MENU_TAG+T_navViewaddSubview:NavBtn];}}//创建滚动菜单-(void)createScrollBtns{floatbtnW=40;UIButton*btn=[UIButtonbuttonWithType:UIButtonTypeCustom];[btnsetFrame:CGRectMake(_topNaviV.frame.size.width-btnW,0,btnW,30)];[btnsetBackgroundImage:[UIImageimageNamed:@"nav_more"]forState:UIControlStateNormal];[_topNaviVaddSubview:btn];[btnaddTarget:selfaction:@selector(showSelectView:)forControlEvents:UIControlEventTouchUpInside];_scrollDataSource=[NSMutableArrayarrayWithObjects:@"推荐",@"电影",@"电视剧",@"卡通",@"综艺",@"体育",@"娱乐",@"新闻",nil];_navScrollV=[[UIScrollViewalloc]initWithFrame:CGRectMake(0,0,self.view.frame.size.width-btnW,MENU_HEIGHT)];_navScrollV.tag=_navScrollVTag;[_navScrollVsetShowsHorizo??ntalScrollIndicator:NO];for(inti=0;i<[_scrollDataSourcecount];i++){UIButton*btn=[UIButtonbuttonWithType:UIButtonTypeCustom];,-5,MENU_BUTTON_WIDTH,MENU_HEIGHT)];[btnsetTitle:[_scrollDataSourceobjectAtIndex:i]forState:UIControlStateNormal];[btnsetTitleColor:[UIColorwhiteColor]forState:UIControlStateNormal];btn.tag=i+1;[btnaddTarget:selfaction:@selector(ScrolBtnActionbtn:)forControlEvents:UIControlEventTouchUpInside];btn.showsTouchWhen;Highlighted=Y[_navScrollVaddSubview:btn];}[_navScrollVsetContentSize:CGSizeMake(MENU_BUTTON_WIDTH*[_scrollDataSourcecount],MENU_HEIGHT)];[_topNaviVaddSubview:_navScrollV];//滚动条底部滚动条_navBgV=[[UIViewalloc]initWithFrame(0,MGRectTTON_WENU),5)];[_navBgVsetBackgroundColor:[UIColorredColor]];[_navScrollVaddSubview:_navBgV];[selfaddView2Page:_scrollVcount:[_scrollDataSourcecount]frame:CGRectZero];}//初始化视图内容显示当前选中滚动内容的btn-(void)addView2Page:(UIScrollView*)scrollVcount:(NSUInteger)pageCountframe:(CGRect)frame{for(inti=0;i
