认识 -addSubview:方法

标签: 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.

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

推荐阅读更多精彩内容

  • ViewsBecause view objects are the main way your applicati...
    梁光飞阅读 316评论 0 0
  • **2014真题Directions:Read the following text. Choose the be...
    又是夜半惊坐起阅读 6,729评论 0 23
  • 生命是父母给的,虽然只有一次,也很短暂;但无比珍贵。每个人的生命都是独一无二的,要爱护它,珍惜它;要对自...
    a3a1eedf828f阅读 132评论 0 1
  • 这是个敏感的词 隐藏着敏感的话语 风中的愁丝 依然混着水蒸气在凝视 我独自站在中大南门的荷花池边 看她们心房盛开的...
    Mosse阅读 99评论 0 1
  • 《相逢是首歌》是一首很经典的歌,每一次听都会很感动,歌里这样唱道:“你曾对我说:相逢是首歌,眼睛是春天的海,青春是...
    梧印墨迹阅读 257评论 2 1
  • 大濛,毕业快乐 北理的四年青春,有三年是和你一起大笑大闹一起神经大条走过的、而如今,你也要毕业了,让我更加思念。怀...
    Serena76阅读 186评论 0 1