ios - Button position different for different iphone -


how can buttons stay on same position different versions of iphone? have background image , on top of that, have button. this iphone 6.

this 1 iphone 5.

is there anyway can provide fixed position button?

the following supposed like, based on story board. enter image description here

all ios devices 4", 4.7", , 5.5" screens (which iphones since iphone 5 , ipods since 5th generation) have same screen aspect ratio, 16:9, if target devices, doable constraints in storyboard , no code.

you posted iphone 6-sized screen shot. (pro tip: press ⌘s in simulator save screen shot desktop don't have try crop hand.) in shot, you've put bottom edge of button 300 pixels = 150 points above bottom edge of screen. screen of iphone 6 667 points tall.

so step 1 add “spacer” view root view. set background color can see, , make hidden. (hidden views still participate in layout.) pin spacer left , bottom edges of root view. make 20 points wide. width doesn't matter. create equal-height constraint between spacer , root view. edit equal-height constraint. set multiplier 150:667 (use string , xcode division you). here's should like:

spacer configured

now constrain bottom edge of button equal top edge of spacer:

button bottom constraint

we can see how button placed on different screen sizes using preview mode in assistant editor:

previews

as requested, button “always on top of blurred yellow line”.

if want support 3.5 inch screens , set mode of background image view “aspect fit” (which leave blank space on sides of image) or “scale fill” (which squash image little bit), layout work as-is.

if want support 3.5 inch screens , use differently-cropped background image (e.g. use mode “aspect fill”), need replace spacer's height constraint in code based on screen size of device.


Comments

Popular posts from this blog

Ansible - ERROR! the field 'hosts' is required but was not set -

customize file_field button ruby on rails -

SoapUI on windows 10 - high DPI/4K scaling issue -