ios - How to Center UI View when in landscape & portrait? -
i having trouble centering 2 uiimages , layer when orientation changes.
here did center
_colorlayer = [calayer layer]; cgrect frame = self.hueimageview.frame; cgsize superviewsize = self.hueimageview.superview.frame.size; self.hueimageview.center = cgpointmake((superviewsize.width / 2), (superviewsize.height / 2)); self.checkeredview.center = cgpointmake((superviewsize.width / 2), (superviewsize.height / 2)); self.labelpreview.center = cgpointmake((superviewsize.width / 2), (superviewsize.height / 2));
this works fine in portrait. when rotate images not go middle .
the project on github https://github.com/rk905/newcolorpic/blob/master/newcolorpic/neocolorpickerhslviewcontroller.m
just set center superview other views. superview.center should it. no fights height/2 , width/2 .
if use constraints, not need set again. align views center.y , center.x of superview. no fight orientations because constrain center automaticly move also
Comments
Post a Comment