Search code examples
iosobjective-cuiviewframeios8-today-widget

Get frame size of UIView - iOS


I have an iOS app with an iOS 8 widget, I am trying to get the size of the frame which contains my widget (NOT the size of the device screen), is this possible?

I have tried the following, but it returns the frame size of the entire device screen which is not what I am looking for.

CGSize sz = [UIScreen mainScreen].bounds.size;

In essence, this is what I am looking for:

enter image description here


Solution

  • Ok no matter, I managed to fix it myself in the end. I just passed in the height of my view in manually to the library I am using so that it works.

    Basically I am using a library called SCLAlertView for a nice popup alert, and to get it to position correctly (vertically) I am now passing in the height of my view, if it is indeed a widget view.