"Vary for Traits" does not work as expected

From what I understand, as explained in the answer to this question , you can resize any component on the storyboard for any device you want, so right where the problem arises. I have an image that has regular resolution: 353x229, and this image looks huge on the iPhone 4s screen, so I want to resize it to 300x194 only on the 4s screen, and that’s how I do it:

First, I click on the Vary for Traits button, then I click on the image, and then click on “Show size inspectors” on the right, and from there I change “Width evenness” to 300 and “Equal heights” to 194, and then I click “Done Varying. "

But the problem is resizing the image for each individual device! Even the iPad! I don’t understand why this is happening and how should I stop it?

+5
source share
2 answers

Perhaps now you understand it. But in case others have a similar problem, here are my 2 cents:

I ran into a similar problem: the label had to have different heights for iPhones and iPads. But every time I changed the height of the shortcut on the iPad, changing the characteristics, it also changed the height on the iPhone.

Here is what I did to fix this:

  • Select an object (in my case, a label)
  • In the Dimension Inspector, double-click on the restriction that you want to change for another device.
  • Click the + sign next to Constant .
  • Select the appropriate features (in my case, the usual height + width for the iPad) and add the changes.
  • Now, under the Constant drop-down menu, you will now see your layout for the corresponding device.
  • Now you can resize the corresponding restriction.

Note that you must do this for each constraint that needs to be changed. I understand that it should also work, choosing the right device and clicking Vary for Traits . But I think this is a buggy, and therefore it is an alternative way to achieve the same.

+8
source

When you select a value for tags, check the box for width when iphone4 is selected. All devices in the blue field will be executed if any restriction is inserted at this time. The iphone4s screen width is compact in portrait mode, and the ipad is ordinary. When resizing, do not do this according to the size indicator, rather add a restriction on position, height and width. So after that, you need to go back to ipad mode and select the checkbox for attributes and width, and then click elsewhere. Here you change the position, height and width in the constraints that can be found in the dimension inspector by clicking edit.

0
source

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


All Articles