ios - Are rotated Views compatible with Auto Layout? -


i have learned how rotate view affine transforms (see here). have learned auto layout (see here , here), , programmatic auto layout (see here , here). however, don't know how auto layout work rotated view.

this image shows do:

enter image description here

i think trouble comes width , height changing because of rotation. there way make rotated view fill it's superview? there trick auto layout work or incompatible after rotation?

(i've learned swift, i'd glad wade through objective-c answers if more familiar with.)

update

following @vinayjain's suggestion did following:

  • pinned subview edges superview in storyboard.
  • created iboutlets spacing constraints on sides of subview.

    @iboutlet weak var rightspace: nslayoutconstraint! @iboutlet weak var leftspace: nslayoutconstraint! @iboutlet weak var topspace: nslayoutconstraint! @iboutlet weak var bottomspace: nslayoutconstraint! 
  • rotated subview

    subview.transform = cgaffinetransformmakerotation(cgfloat(m_pi_2)) 
  • changed constraints outlets

    self.rightspace.constant = cgfloat(0) self.leftspace.constant = cgfloat(0) self.topspace.constant = cgfloat(0) self.bottomspace.constant = cgfloat(0) 

but @ point realized don't need change spacing value. want spacing remain 0. need adjust itself. however, rotation messes up. effect shown in following image:

enter image description here

you can autolayout easily,

  • create constraints pinning edges superview
  • create outlets these constraints(say leftspace,rightspace,topspace,bottomspace)

  • check rotation, , update these values accordingly

use check rotation : check rotation


Comments

Popular posts from this blog

javascript - Google App Script ContentService downloadAsFile not working -

javascript - Function overwritting -

php - Find a regex to take part of Email -