[IOS] Translate size Classes with Xcode 6:one Storyboard for all Sizes

Source: Internet
Author: User

Size Classes with Xcode 6:one Storyboard for all Sizes

Prepare a storyboard for all sizes

My favorite Xcode6 feature is the new size classes concept, and with it, we've solved "how can I quickly write apps for so many different screen sizes and directions." They also let you create a generic app in a storyboard. By federating with the new Adaptive screen controller, it is easier to rely on interface builder than against it, simplifying the layout of your application.

Each view controller in the app has a special collection object, and this particular collection object has two size classes, a horizontal size class with a vertical size class. And each class has 3 possible values: Compact,regular, or any. These values can be changed based on the device and direction. Your app will layout its interface for each view controller based on the current size classes. Apple uses a grid to let the user choose which setting to work on, so here's a grid containing the device and the direction,

The corresponding size class combination is highlighted.

An interesting thing: the ipad is regular x regular.

Straight from Apple's ' s ' s ' New in IOS8 Guide ':

With the amount of screen space available, the IPad have a regular size class in the vertical and horizontal directions in Both portrait and landscape orientations. "

-dr. dre* "Here is a passage from the original

All right, here's the book material, then open Xcode6 let's try it. According to Apple's NDA and XCODE6, and the following are all from XCODE5, so these pictures are just some guide.

Create a new generic project. If you want to try the XCODE6 project, you need to activate the size classes option. You can check the AutoLayout option in Interface Builder.

First, let me look at the grid of size class in Xcode. This is an area where you can switch between different layout arrangements. When you look at the storyboard, see the bottom of the view, and click on the label ' Wany HAny '. You'll see some grid-like images.

By default, we start with a basic setting, which is the any width and any height. Many things will be placed and changed here, including the default layouts for all directions of the iphone and ipad. Apple recommends setting most of the settings in this interface. This is particularly simple because of the reduced workload. Let's lay out a super wide button in the middle of the screen. Give it a green background so that we can see its true size, give it a restraint to center him

and gives it an exaggerated fixed width of 600.

Well, now that the ipad and iphone simulator are running, you'll see that it's all centered, but the iphone's two directions are too wide, so let's fix it with size classes. Back to the first picture of the grid selection of the iphone screen settings, is the compact width+ regular height. The red rectangle in the grid.

You will notice that the bar at the bottom is changed to blue after you select it in the grid. That is warning you: "Hey, you are not in a basic setting, and some changes will be displayed when you run the value." So this bar is now blue! "Some of the changes I've made are because there are four things you can change." Size classes:1 constraint constant, 2 font, 3 constraint on/off, 4 child view on/off

The first two are completely self--first come here next update

[IOS] Translate size Classes with Xcode 6:one Storyboard for all Sizes

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.