ios - auto resizing sub views in iphone/ipad? -
i have view(name "myview") in have 4 subviews - 2 uiimageview's, 2 uilabel's.i have place view in other view (where ever requires).while placing myview have give frame(any frame).according frame given "myview" subview's should adjusted position , size (auto adjust according original place , size). if remove 1 of 4 subviews "myview" remaining 3 subviews should automatically adjusted within "myview". should achieve without "autolayout" support older versions. have used autoresizingmask properties in ib, didnt desired result.
can me in how achieve this.
without autolayout can't suffisticated layout out of box.
you have write custom subclass myview
. overwrite it's layoutsubviews
(this beeing called everytime view's frame changes) reposition , resize subviews.
@interface myview : uiview @property (weak, nonatomic) iboutlet uiimageview *iv1; @property (weak, nonatomic) iboutlet uiimageview *iv2; @property (weak, nonatomic) iboutlet uilabel *label1; @property (weak, nonatomic) iboutlet uilabel *label2; //... @end @implementation myview - (void)layoutsubviews { cgrect frame = self.iv1.frame; frame.origin.x = somevalue * self.bound.size.width; frame.origin.y = ...; self.iv1.frame = frame; ... }
Comments
Post a Comment