这个方法会使被添加的view内存计数+1
Adds a view to the end of the receiver’s list of subviews.
把一个视图添加到接收者子视图列表的尾部。
func addSubview(_ view: UIView)
参数
The view to be added. After being added, this view appears on top of any other subviews.
要被添加的视图。添加以后,这个视图会出现在其他所有子视图的顶部。
讨论
This method establishes a strong reference to view and sets its next responder to the receiver, which is its new superview.
这个方法对视图建立一个强引用并且把接收者设置为它的下一个响应者,也是它的新的父视图。
Views can have only one superview. If view already has a superview and that view is not the receiver, this method removes the previous superview before making the receiver its new superview.
每个视图只能拥有一个父视图。如果视图已经有了一个父视图并且那个视图不是接收者,这个方法会移除先前的父视图,然后才把接收者设置为新的父视图。