美文网首页
认识 -addSubview:方法

认识 -addSubview:方法

作者: 梅西和他的世界杯 | 来源:发表于2016-01-17 15:32 被阅读386次

    标签: iOS,苹果开发文档


    • addSubview:
      Adds a view to the end of the receiver’s list of subviews.

    Declaration

    SWIFT
    func addSubview(_ view: UIView)
    OBJECTIVE-C
    - (void)addSubview:(UIView * _Nonnull)view
    

    Parameters

    view
    The view to be added. After being added, this view appears on top of any other subviews.
    这个视图被添加,添加之后,这个视图会显示在其他所有子视图的上面。

    Discussion

    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.

    视图仅仅会有一个父视图。如果视图已经有一个父视图并且它不是这个视图的接收者,这个方法会把视图移除从前一个父视图,再加到新的父视图中。

    相关文章

      网友评论

          本文标题:认识 -addSubview:方法

          本文链接:https://www.haomeiwen.com/subject/lvqkkttx.html