-1

I've used Auto resize in Interface Builder and It's Works fine. But I want to know how to do that in programmatically. Because i want to change AutoResizing mask in ViewDidload according iPhone Series.

The Code I've used is given below:

_moreOptionsView.autoresizingMask = (UIViewAutoresizingFlexibleHeight|UIViewAutoresizingFlexibleWidth|UIViewAutoresizingFlexibleLeftMargin|UIViewAutoresizingFlexibleBottomMargin);

I want to set Auto Resizing Mask to Width, Height, Right Margin & Top Margin through Programmatically.

Politank-Z
  • 3,653
  • 3
  • 24
  • 28
Balaji Ramakrishnan
  • 1,909
  • 11
  • 22
  • 1
    possible duplicate :/ http://stackoverflow.com/questions/10468389/uiview-autoresizingmask-interface-builder-to-code-programmatically-create-st – Gürhan KODALAK Jun 17 '15 at 12:09
  • where are you checking this?? few days back i was also doing the same then i found out that it works below iOS 7 not in iOS 8 and above. Why? i dont know but it may help you. :) – Aanabidden Jun 20 '15 at 14:11

2 Answers2

2

You simple have to set the Autoresizing Mask of the view in question like so:

myView.autoresizingMask = UIViewAutoresizingFlexibleBottomMargin | UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleRightMargin | UIViewAutoresizingFlexibleTopMargin;

This is achieved using the Bitwise OR operator. It will set all bits true that are true in either of both values provided.

Woodstock
  • 22,184
  • 15
  • 80
  • 118