如何将一个UICollectionViewCell嵌套在另一个中?

时间:2018-09-06 10:40:38

标签: ios swift xcode uicollectionview uicollectionviewcell

以下是我的老问题hereHow to add UIView inside a UITableViewCell Programmatically?

我想通过在这些collectionViewCell卡中添加更多元素来获得类似于iOS 11 Today选项卡的增强视图。

我想在CollectionViewCell卡(“ App Store Today”选项卡单元)中添加像Netflix或其他AppStore选项卡那样的双向滚动(游戏和应用程序)。这是我想要的概述: enter image description here

请告知是否有可能实现这种目标。如果是,那怎么办? 谢谢。

1 个答案:

答案 0 :(得分:0)

import Foundation
import UIKit

class ObjCell: UICollectionViewCell{

let leftView: UIView = {
    let view: UIView = UIView()
    view.backgroundColor = UIColor.red
view.frame = CGRect(x:20, y:50, width:320, height:50)
    view.translatesAutoresizingMaskIntoConstraints = false
    return view
}()

override init(frame: CGRect) {
    super.init(frame: frame)

    setCellUI()
}

required init?(coder aDecoder: NSCoder) {
    fatalError("init(coder:) has not been implemented")
}

func setCellUI(){

    backgroundColor = UIColor.yellow
    addSubview(leftView) 
}
}