Change device-based restrictions at runtime

I use Storyboard to set my limits. Although everything is perfect, I have some ideas where I want to change the restrictions on only a 3.5 "device.

Is it possible? How can i do this?

+3
source share
1 answer

You can define a macro to determine the size of the screen, for example:

#define isiPhone4 ([[UIScreen mainScreen] bounds].size.height == 480)?TRUE:FALSE

Later in the code, you can do something like this:

if (isiPhone4) {
    self.constraint.constant = NEW_VALUE;
}

To access the storyboard lines from the code, you have to do them IBOutlets(control + drag them to your controller, like everything else).

enter image description here

+5
source

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


All Articles