關(guān)于addSubview(_:)

蘋果文檔

這個(gè)方法會(huì)使被添加的view內(nèi)存計(jì)數(shù)+1

Adds a view to the end of the receiver’s list of subviews.
把一個(gè)視圖添加到接收者子視圖列表的尾部。

func addSubview(_ view: UIView)
參數(shù)

The view to be added. After being added, this view appears on top of any other subviews.
要被添加的視圖。添加以后,這個(gè)視圖會(huì)出現(xiàn)在其他所有子視圖的頂部。

討論

This method establishes a strong reference to view and sets its next responder to the receiver, which is its new superview.
這個(gè)方法對(duì)視圖建立一個(gè)強(qiáng)引用并且把接收者設(shè)置為它的下一個(gè)響應(yīng)者,也是它的新的父視圖。

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.
每個(gè)視圖只能擁有一個(gè)父視圖。如果視圖已經(jīng)有了一個(gè)父視圖并且那個(gè)視圖不是接收者,這個(gè)方法會(huì)移除先前的父視圖,然后才把接收者設(shè)置為新的父視圖。

?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容