Before we get started, recall that the starting point is the top left corner of the CGPoint view. An important thing for understanding the views and parents.
Let's look at this simple code, a view controller, which adds a black square to it:
class ViewController: UIViewController { override func viewDidLoad() { super.viewDidLoad()
This will create this view: the beginning and center of the black rectangle correspond to the same coordinates as its parent

Now try adding subView another SubSubView and give subSubview the same origin as subView, but make subSubView a child of the subView
We will add this code:
var subSubView = UIView(); subSubView.frame.origin = subView.frame.origin; subSubView.frame.size = CGSizeMake(20, 20); subSubView.backgroundColor = UIColor.purpleColor() subView.addSubview(subSubView)
And this is the result:

Because of this line:
subSubView.frame.origin = subView.frame.origin;
You expect the purple source of the rectangle to be the same as its parent (black rectangle), but it goes under it, and why? Since when you add a view to another view, the subView "world" frame is now the parent BOUND RECTANGLE, if you have an idea that the origin on the main screen is at the coordinates (15.15) for all its submenus, the top left the angle will be (0,0)
This is why you need to always refer to the parent using the bound rectangle, which is the "world" of its sub-objects, to fix this line:
subSubView.frame.origin = subView.bounds.origin;
And, having seen the magic, subSubview is now exactly in it with parental origin:

So, you like "okay, I just wanted to focus my opinion on my parents' opinion, what is it?" well, it doesn’t really matter, you just need to “translate” the parent point of the center, which is taken from it to the center of the parent boundaries thereby:
subSubView.center = subView.convertPoint(subView.center, fromView: subSubView);
In fact, you are telling him: “Take your parents to the viewing center and transform it into the world of subSubView.”
And you get this result:
