How to nest a UICollectionViewCell inside another

2019-08-20 09:03发布

Following my old question here: How to add UIView inside a UITableViewCell Programmatically?

I wanna achieve an enhanced view like that of iOS 11 Today tab with adding more elements in those collectionViewCell cards.

I want to add biDirectional Scrolling like that of Netflix or other AppStore tabs(Games & Apps) inside my CollectionViewCell card(App Store Today tab cells). Here is an overview of what I want: enter image description here

Please tell is it possible to achieve such thing. If yes then how? Thanks.

1条回答
女痞
2楼-- · 2019-08-20 09:47
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) 
}
}
查看更多
登录 后发表回答