How to nest a UICollectionViewCell inside another one?

这一生的挚爱 提交于 2019-12-13 03:44:00

问题


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:

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


回答1:


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) 
}
}


来源:https://stackoverflow.com/questions/52202237/how-to-nest-a-uicollectionviewcell-inside-another-one

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!