Created
April 25, 2023 12:47
-
-
Save elmoswelt/3739172d6bf3dbf803bd20fe9b2dfc2e to your computer and use it in GitHub Desktop.
Generic Cell's
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class ContainerCollectionViewCell<ContainedView: UIView>: UICollectionViewCell { | |
// MARK: - Properties | |
public let containedView = ContainedView() | |
//MARK: Initialization | |
override public init(frame: CGRect) { | |
super.init(frame: frame) | |
setup() | |
} | |
required init?(coder: NSCoder) { | |
fatalError("init(coder:) has not been implemented") | |
} | |
// MARK: - Setup | |
private func setup() { | |
backgroundColor = .clear | |
contentView.addSubview(containedView) | |
containedView.pin(to: contentView) | |
} | |
} | |
public class ContainerTableViewCell<ContainedView: UIView>: UITableViewCell { | |
//MARK: Public | |
public let containedView = ContainedView() | |
//MARK: Initialisation | |
override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) { | |
super.init(style: style, reuseIdentifier: reuseIdentifier) | |
setup() | |
} | |
public required init?(coder: NSCoder) { | |
fatalError("init(coder:) has not been implemented") | |
} | |
//MARK: Setup | |
private func setup() { | |
contentView.addSubview(containedView) | |
containedView.pin(to: contentView) | |
backgroundColor = .clear | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment