I have a view that appears at the center of its parent view portrait mode, what autoresizemask should I use so that it appears in the center in landscape mode too. It's size should remain same.I just want its origin should shift themselves automatically at the point so that it appears at the center.Any help please?
I have given
[parentView setAutoResizesSubview:YES];
parentView.autoresizingMask = UIViewAutoresizingFlexibleHeight|UIViewAutoresizingFlexibleWidth;
An integer bit mask that determines how the receiver resizes itself when its superview's bounds change.
Autoresizing masks is a layout method using a bit mask, or an encoded set of flags, that defines how a view should respond to changes in the superview's bounds. The properties available in a autoresizing mask on a view are: Flexible Top Margin, meaning resizing can change the view's top margin.
Views are the fundamental building blocks of your app's user interface, and the UIView class defines the behaviors that are common to all views. A view object renders content within its bounds rectangle, and handles any interactions with that content.
// horizontal
childView.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleRightMargin;
// vertical
childView.autoresizingMask = UIViewAutoresizingFlexibleTopMargin | UIViewAutoresizingFlexibleBottomMargin;
// both
childView.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleRightMargin | UIViewAutoresizingFlexibleTopMargin | UIViewAutoresizingFlexibleBottomMargin;
Swift 3:
childView.translatesAutoresizingMaskIntoConstraints = false
childView.autoresizingMask = [.flexibleTopMargin, .flexibleBottomMargin, .flexibleLeftMargin, .flexibleRightMargin]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With