1

UIStackView in iOS 9 has been great.

However, when trying to access the center property of a UIView that fills one of the lower child views within the UIStackView, xcode returns (187.5, 30.5)

The view is actually located at the bottom of the screen. More like (208, 673) on my 5.5" iPhone

I believe xcode is returning the center point in relation to the containing stack child view, however I need to know where the view is in relation to the whole screen.

How then would I find the point on the screen my view is located?

YichenBman
  • 5,011
  • 8
  • 46
  • 65
  • 2
    You might be interested in this [answer](http://stackoverflow.com/questions/2073427/convert-coordinates-between-parent-child-uiview-after-cgaffinetransform) – Matteo Piombo Jul 21 '15 at 05:14

1 Answers1

1

You can get the frame rect of the UIStackView cell simply getting the frame of the superview (Supposing that the UIStackView's parent is the main view). Something like:

UIView
   |
   +-- UIStackView
          |
          +-- targetUIView *

So, to know the position of the targetUIView relative to the main UIView, you should call something like:

CGRect location = targetUIView.superview.frame;

Regards

Anibal Itriago
  • 1,051
  • 10
  • 13