Xcode 6 Class Classes

I would like to ask a question about a very confusing (at least to me) topic - size classes in Xcode 6. I tried to get a complete picture of how this all works, but it is still unclear what I am.

Before Xcode 6 and the new iPhones, everything was very simple. To, Non-Retina and Retina, which allow us to work with the same resolution of 320x480 (or 568 for higher devices). Standard and @ 2x assets made sense. Now, however, we have large rear screens with the same ratio (almost the same), but the workspace is no longer the same.

Varieties of classes should do everything possible to make it all in one storyboard. But wait .. iPhone 6 uses @ 2x assets, which, in my opinion, means that there will be less graphics on this device than on iPhone 5 / 5S. And the iPhone 6 Plus uses @ 3x assets, which again will not look the same. It seems that it is impossible to make, for example, a certain button that is always the same size with respect to, say, the full width of the screen. If we do not code it, of course, but it will make the classes of classes useless.

Do I understand things correctly or am I missing something? It would be great to hear how you all see it. Maybe you know some good tutorials? I did not find anything that could explain my doubts.

Thanks in advance!

+5
source share
2 answers

You can do a lot of what you say here using a combination of different approaches:

  • Dimension classes for different types of devices that cover the most extensive user interface configuration changes (for example, differences between iPad and iPhone). You can use this to change, for example, the sidebar.

  • Auto-detection rules specific to individual dimension classes. You can add different autodetection rules for different size classes to customize the layout (for example, you can switch between the horizontal row of buttons and the stack of button columns this way, since now you can have different Autolayout rules for different size classes). This method is extremely effective if you realize that you no longer need to use the same autodetection rules for all dimension classes.

  • Asset catalogs automatically switch pre-rendered graphics for different supported resolutions, etc. Please also note that since many older devices do not actually support iOS 8, you no longer need to include low-resolution versions unless you need extensive backward compatibility (and if you do, not all class class features are available like this or otherwise). I just made a new version of the application that only supports iOS 8, as users in older versions will simply get the previous version of the application.

  • Volatile Images: Now you can specify mutable areas in images to control how they stretch when applied to things like UIButtons, etc. that can resize according to Autolayout rules. (This is a feature of Android for a long time, so it is welcomed on iOS.) This means that you can make things look good on a wider range of screen sizes without having so many separate images or precisely controlling the size of the user interface elements.

  • Program code in view controllers to configure everything that you cannot achieve in another way.

While it’s true that you don’t have exactly that kind of fined control over which devices show the exact layout with size classes, I found that it’s not as big a problem as you might think, since size classes allow your view controllers to be very easy adapt to various devices. The combination of autospass classes and sizes is particularly effective. And this is actually potentially good, because it means that setting Apple to a different screen size requires less than a new manual setting. It's a bit of a pain right now to convert, but it's probably worth it in the long run. You just need to think about how you changed the situation differently. This is a bit more like Android, where they have long had to deal with many different sizes and resolutions of the device’s screen, but it’s also a kind of natural evolution of the platform, where you cannot exactly design for each physical device as a practical question (you should still test on them in the simulator).

+4
source

A variety of classes do not just adapt to larger screen sizes, they exist for completely different layouts. Like on the iPhone, you can show one item and click to go to the next screen for more information, but on the iPad you show both on the same screen.

For small settings, you use automatic layout, with different layouts for each size class, and different screen sizes in each size class are processed automatically.

0
source

Source: https://habr.com/ru/post/1205098/


All Articles