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.
is there anyway can provide fixed position button?
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:
now constrain bottom edge of button equal top edge of spacer:
we can see how button placed on different screen sizes using preview mode in assistant editor:
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
Post a Comment