0

I have to set autoresizingMask programmatically for UIView.

I don't know how to implement this.

Screenshot of autoresizing which i want to implement

JAL
  • 41,701
  • 23
  • 172
  • 300
Nisha Nair
  • 327
  • 1
  • 5
  • 17
  • 1
    Possible duplicate of [Center UIButton programatically](http://stackoverflow.com/questions/8908510/center-uibutton-programatically) – Swapnil Luktuke Nov 18 '15 at 07:46
  • 1
    1. Use autolayouts instead of the older autoresizing. 2. 'Autoresizing programatically' has been asked and answered many many times before. Search before posting a new question. Read [How to Ask](http://stackoverflow.com/help/how-to-ask) – Swapnil Luktuke Nov 18 '15 at 07:48

3 Answers3

0

This is how you need to set it.

yourView.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleBottomMargin;
Pratyusha Terli
  • 2,343
  • 19
  • 31
0

To achieve what you have in that screen shot you need to do the opposite of what DrummerB suggests. You want a fixed top margin and right margin so you make every other side flexible like so:

view.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleBottomMargin;
Piyush
  • 1,534
  • 12
  • 32
0
view.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleBottomMargin;

If you want to know the concept very clearly,

UIView's autoresizing mask programmatically

View AutoResizingMask Constant

UIView AutoResizingMask

Autoresizing masks programmatically vs Interface Builder / xib / nib

Community
  • 1
  • 1
user3182143
  • 9,459
  • 3
  • 32
  • 39