ios - Need assistance regarding auto layout -


enter image description here

i placed uiview of size w=140, h=33 @ position x=16 ,y=20 , applied these constraints.

enter image description here

i want uiview display on half of screen no matter orientation or screen size is.

but result in portrait orientation

enter image description here

and in landscape orientation uiview vanish.

why getting behavior, in autolayout view width & height calculated on bases of constraints.

i managed figure out how achieve looking for. it's rather simple once figure out. firstly, clear constraints. position uiview across of screen so:

view

then, add constraints 0 superview.

constariants

edit: need use multiplier 2 half box size.

then, go size inspector, , select trailing space superview , click edit. you'll presented edit screen, see multiplier property. set 0.5, , voila it'll go middle of screen.

superview

consider adding height constraint, if don't view get's compressed. it's simple. view automatically update, , you'll final result: enter image description here

hope helps, julian


Comments