I created a UIView in a Storyboard that should be centered exactly in the center of the View Viewer with automatic layout and works great in different device sizes. I call it largerView .
However, I would like to programmatically create a smaller UIView called smallerView and center this view to smallerView.center = largerView.center .
I ran into a problem when using largerView using an automatic layout , whenever I use the method above, my smallerView never centered with largerView.center . I noticed that it will take the center coordinates of largerView as they appear on the Storyboard, based on the specific layout of the device I use (in this case, the previous iPhone 5 sizes), but not the updated center, which is affected by the automatic layout.
A similar problem can be discussed here, except that it is based on Swift. I know how constraints are created programmatically, but I'm not sure how to get the "updated" view coordinates after an automatic layout.
Thanks!
source share