iOS full screen background, multiple button position adaptation (SWIFT)

Source: Internet
Author: User

Recently written blog more, in fact, most of the previous essays, this section of the collation, released.

Today's article, say, face full-screen background image, to place multiple buttons in a fixed position of the problem of my solution, in fact very earth, not technically, is a method, very labor-saving.

This is the picture. Repeat the question: for example, I want to place five buttons on the full-screen background of M U R P and visit the official website Five places, which requires a variety of models of mobile phones.

That's what I'm dealing with (StoryBoard):

First: Drag 4 Viewcontroller inside the storyboard to set the size of screen size 3.5, 4.0, 4.7, 5.5, respectively. Then set up the background picture separately and place the fixed button in the fixed place.

Then in the use of the time by judging the different screen size, to load the different storyboard, the code is as follows: (Swift).

1Let ScreenHeight =Uiscreen.mainscreen (). Bounds.size.height2         varStoryboards:uistoryboard = Uistoryboard (name:"Main", Bundle:nil) asUistoryboard3         if(ScreenHeight <=480.0) {4             5Viewcon = Storyboards.instantiateviewcontrollerwithidentifier ("First3.5") as!Firstviewcontroller6}Else if(ScreenHeight <=568.0) {7             8Viewcon = Storyboards.instantiateviewcontrollerwithidentifier ("First4.0") as!Firstviewcontroller9}Else if(ScreenHeight <=667.0) {Ten              OneViewcon = Storyboards.instantiateviewcontrollerwithidentifier ("First4.7") as!Firstviewcontroller A}Else if(ScreenHeight <=736.0) { -              -Viewcon = Storyboards.instantiateviewcontrollerwithidentifier ("First5.5") as!Firstviewcontroller the         } -          -         varNavicon:mainnavigationcontroller = Mainnavigationcontroller (Rootviewcontroller:viewcon)

In this way, you can all fit in.

Want to see the code of the small partner:--> GitHub: to demo of the small partners look over

iOS full screen background, multiple button position adaptation (SWIFT)

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.