I would like to know if there is any possible way through which I can dynamically change the position of a UIButton depending on screen size of the phone(4s, 5-series and 6)
Thanks in advance.
I would like to know if there is any possible way through which I can dynamically change the position of a UIButton depending on screen size of the phone(4s, 5-series and 6)
Thanks in advance.
There are multiple ways to solve this issue:
1) With AutoLayout you can specify rules which describe how views relate to each other. This will allow the app to intelligently adapt to any screen size, if thoughtfully implemented.
2) You can check the device version at runtime and programmatically layout your view appropriately.
1 is the preferred solution, and is best practice on iOS.
As Woodstock as suggested you can use Autolayout. But if you are familiar with it and have a simple use-case, you can use the [UIScreen mainScreen] bounds].size.height
property to get height of the screen and compare it with the sizes of the different devices using the if/switch and then accordingly call the following in each of the cases to adjust its position accordingly.
[button setCenter:<CGPoint calculated goes here>];
For the Autolayout approach you can checkout this answer.