簡體   English   中英

子視圖位於邊界層下方 - Swift - 以編程方式

[英]Subview goes beneath border Layer - Swift - Programmatically

我以這種方式設置 UICollectionViewCell 的邊框:

theView.layer.borderWidth = 5
theView.layer.borderColor = UIColor.white.cgColor

問題是我在這個 collectionviewcell 上添加了一個子視圖,它像這樣在邊界下方:

在此處輸入圖片說明

我實際上想將子視圖放在 CollectionViewCell 上

將子視圖添加到單元格的代碼:

plusImageView.translatesAutoresizingMaskIntoConstraints = false
    addSubview(plusImageView)
    plusImageView.centerYAnchor.constraint(equalTo: bottomAnchor).isActive = true
    plusImageView.centerXAnchor.constraint(equalTo: trailingAnchor).isActive = true

https://developer.apple.com/documentation/uikit/uiview/1622541-bringsubviewtofront

將子視圖添加到父視圖后,使用 parentView.bringSubviewToFront(subview)。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM