0

I have a button, created in storyboard and linked in my .h using

@property (strong, nonatomic) IBOutlet UIButton *gridLabel;

I'm trying to find out how big it is inside the viewDidLoad of my .m. For this I use

_gridLabel.bounds.size.width

But this always gives out a fixed number, no matter how big the button actually is. How can I make it work?

I am also getting the size of the screen using

[[UIScreen mainScreen] bounds].size.width

and this seems to work. So can I do something similar

[[something _gridLabel] bounds].size.width

If so, what is the something?

rmaddy
  • 314,917
  • 42
  • 532
  • 579
quantum_jim
  • 208
  • 2
  • 10
  • 9
    in `viewDidLoad` there is no correct bounds. Try `viewWillAppear` or `viewDidLayoutSubviews` – Nikita Took Jan 11 '16 at 13:46
  • 3
    Possible duplicate of [iOS AutoLayout - get frame size width](http://stackoverflow.com/questions/12527191/ios-autolayout-get-frame-size-width) –  Jan 11 '16 at 13:48
  • Thanks to both. viewDidLayoutSubviews seems to be working. – quantum_jim Jan 11 '16 at 14:06

0 Answers0