The Code Essence section is as follows:
//1. Add ScrollView /*1). Add a ScrollView; 2). Create a focus, hot, nearby three controllers. 3). Store their names in the array, traverse and place them into the controller. 4). Set the contentsize of the ScrollView. 5). Set the offset of the scrollview. 6). Called when the Stop animation method is set to the current ScrollView. (should be the way to stop dragging)*/Nsarray*controls = @[@"Strfollowviewcontroller",@"Strhotviewcontroller",@"Strnearviewcontroller"]; for(Nsinteger i =0; i < Controls.Count; i++) {Uiviewcontroller*VC =[[Nsclassfromstring (Controls[i]) alloc] init]; Vc.title=Self.titlenames[i]; [Self ADDCHILDVIEWCONTROLLER:VC]; } self. Mainscrollview.contentsize= Cgsizemake (Self.titleNames.count *[uiscreen mainscreen].bounds.size.width,0); Self. Mainscrollview.contentoffset= Cgpointmake (Screen_width,0); [Self scrollviewdidenddecelerating:self. Mainscrollview];}//2. Setting up the agent#pragmaMark Scrollviewdelegate-(void) Scrollviewdidenddecelerating: (Uiscrollview *) scrollview{[self Scrollviewdidendscrollinganimation:scrollview];}- (void) Scrollviewdidendscrollinganimation: (Uiscrollview *) scrollview{/** 1. Get the width and height, also open the paging function 2. Gets the index value. 3. Set the offset 4. Set the Viewframe to not return 5 if it has not been loaded again. Adding a sub-controller view to ScrollView*/Nsinteger Width=Screen_width; Nsinteger Height=Screen_height; CGFloat OffsetX=Scrollview.contentoffset.x; Nsinteger Index= offsetx/width; [Self.topview Topviewwithindex:index]; Uiviewcontroller*VC =Self.childviewcontrollers[index]; if([VC isviewloaded])return; Vc.view.frame= CGRectMake (OffsetX,0, width, height); [Self. Mainscrollview AddSubview:vc.view];}//3. Add TopView-(Strtopview *) topview{if(!_topview) {_topview= [[Strtopview alloc] Initwithframe:cgrectmake (0,0, $, -) TitleNames:self.titleNames tagblock:^(Nsinteger index) {[Self. Mainscrollview Setcontentoffset:cgpointmake (Index*screen_width,0) Animated:yes]; }]; } return_topview;}
ScrollView View analysis of columns