I created an UIView
in Storyboard that is to be centered exactly in the center of the View Controller with auto layout, and is working fine across different device sizes. I call this largerView
.
However, I would like to programmatically create a smaller UIView
called smallerView
and center the this view so that smallerView.center = largerView.center
.
I am running into an issue where given that auto layout is used on largerView
, whenever I use the method above, my smallerView
never actually centers with largerView.center
. I noticed that it will take the center coordinates of largerView
as they appear in Storyboard, based on the specific layout of the device I am using (in this case, the previous iPhone 5's dimensions), but not the updated center as affected by auto layout.
A similar issue may be discussed here, except it is based on Swift. I know how constraints are created programmatically, but am unsure how to get the "refreshed" coordinates of a view after auto layout is applied.
Thanks!