Thursday, 15 March 2012

ios autolayout autoresizing does not work -


I have just focused a button horizontally and vertically and fixed its height.

When I run into the emulator, comparing the heights for the program and the iPhone 6 + and the iPhone 6, the height of the button is very low for 6+ to 6, that's fine.

However in the 4S emulator, the height of the button is similar to the height of one in the iPhone 6. Can anyone explain why this happens? 4 is slightly smaller than the height of the screen, but the height of the button is the same.

This fact produces many problems for me to create a good user interface to be suited for all iPhone devices. I always have such a problem that I need some thing, for example, when the button is smaller in the 4S when I make it smaller, then it is too small for 6 or 6 plus

thanks

If you have a fixed height halt then the button will be the same height on all devices. You can create a IBOutlet for your height hurdle and change it to code at the desired size for each screen size.

  @interface MyResizingButton () @property (nontomic, weak) IBotatable NSLUTE content * Height moderate; @end @implementation IMScrollViewFillingView - (zero) layout attributes {[auto. Tissue Restraint Set Constant: 0.3 * CGRT GateHight (Self Supervisive Frame)]; [Super layout index view]; } @end  

The above code will make your button smaller or larger supervision depending on the size I think the button is added to a scene Sizes vary depending on the screen size (like the root view in UIViewController ). You may need to adjust the calculation to fit your design.

As you can see, I have created a custom UIButton class to handle this adjustable height. To make it work, you can enter UIButton The class of storyboard must be set in . Of course, you can add code directly to your visual controller, you will not need a custom button class.

Another option would not be to use a certain height, but using the height of the button something else, using the aspect ratio constraints, since I really do not know how to interface your interface Works, so I can not really give you a concrete example for this matter.

Hope this will help you to fix your problem.


No comments:

Post a Comment