iOS Development Note (Swift)-implementation of the Generic App Installation Guide page

Source: Internet
Author: User

Previous projects have been developed based on OC and have recently begun to attempt to rewrite the entire project using the Swift language.

This article focuses on how to use Swift to implement a common general-purpose app installation boot interface.

Effect preview:

Implementation ideas:

The main use of Uiscrollview as a container, the width of its contentsize set to (Guide page number) * screen width, and set pagingenabled to True, hide the scroll bar. As instructed Uipagecontrol and Uiscrollview are added directly above the Self.view, and save the Uipagecontrol on top.

Implementation code:

ImportUIKitclassYsyguideviewcontroller:uiviewcontroller,uiscrollviewdelegate {var scrollview:uiscrollview!var Pagecontrol:uipagecontrol!var Startbtn:uibutton!override func Viewdidload () {Super. Viewdidload ()//Do any additional setup after loading the view.loadcustomlayout ()} override func didreceivememorywarning () {Super. didreceivememorywarning ()//Dispose of any resources the can be recreated.    }        //ScrollView Delegatefunc Scrollviewdidscroll (scrollview:uiscrollview) {var offset=Scrollview.contentoffset pagecontrol.currentpage=int (offset.x/yunshouyi.screen_width)if(pagecontrol.currentpage==2) {Startbtn.hidden=false        }Else{Startbtn.hidden=true        }    }        //loading a custom layoutfunc loadcustomlayout () {ScrollView=uiscrollview (frame:cgrectmake (0, 0, Yunshouyi.screen_width, Yunshouyi.screen_height)) Scrollview.pagingenabled=trueScrollview.showshorizontalscrollindicator=falseScrollview.showsverticalscrollindicator=falsescrollview.contentsize=cgsizemake (*yunshouyi.screen_width, Yunshouyi.screen_height) forI in 1...4{var image=uiimage (named: "Guideline-\ (i)") var ImageView=Uiimageview (image:image) imageview.frame=cgrectmake (CGFloat (i-1) *yunshouyi.screen_width, 0, Yunshouyi.screen_width, yunshouyi.screen_height) Imageview.contentmode=Uiviewcontentmode.scaletofill Scrollview.addsubview (imageView)} pagecontrol=uipagecontrol (Frame:cgrectmake (yunshouyi.screen_width/2-100, yunshouyi.screen_height-100, 200, 100)) Startbtn=uibutton (Frame:cgrectmake (yunshouyi.screen_width/2-60, yunshouyi.screen_height/2+50, 120, 35)) Pagecontrol.numberofpages=3; Pagecontrol.currentpage=0Startbtn.settitle ("Immediate experience", ForState:UIControlState.Normal) startbtn.setbackgroundimage (UIImage (named:"Startbutton"), ForState:UIControlState.Normal) Startbtn.settitlecolor (Uicolor.whitecolor (), ForState:UIControlState.Norma L) Startbtn.addtarget (Self, Action:"Guideover", forControlEvents:UIControlEvents.TouchUpInside) Startbtn.hidden=truescrollview.bounces=falsescrollview.delegate=Self self.view.addSubview (scrollView) Self.view.addSubview (Pagecontrol) Self.view.addSubview (star TBTN)}//get started with appsfunc guideover () {var mainvc=Uinavigationcontroller (Rootviewcontroller:uitableviewcontroller ()) Self.presentviewcontroller (MainVC, Animated:true, Completion:nil)} Override Func Prefersstatusbarhidden ()-Bool {return true    }    }

iOS Development Note (Swift)-implementation of the Generic App Installation Guide page

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.