Commit 6fbfcb75 by Daniel Dahan

development: added default registry of CollectionViewCell to CollectionView

parent fc9c0582
...@@ -104,21 +104,24 @@ open class CollectionView: UICollectionView { ...@@ -104,21 +104,24 @@ open class CollectionView: UICollectionView {
An initializer that initializes the object. An initializer that initializes the object.
- Parameter collectionViewLayout: A UICollectionViewLayout reference. - Parameter collectionViewLayout: A UICollectionViewLayout reference.
*/ */
public convenience init(collectionViewLayout layout: UICollectionViewLayout) { public init(collectionViewLayout layout: UICollectionViewLayout) {
self.init(frame: .zero, collectionViewLayout: layout) super.init(frame: .zero, collectionViewLayout: layout)
prepare()
} }
/** /**
An initializer that initializes the object. An initializer that initializes the object.
- Parameter frame: A CGRect defining the view's frame. - Parameter frame: A CGRect defining the view's frame.
*/ */
public convenience init(frame: CGRect) { public init(frame: CGRect) {
self.init(frame: frame, collectionViewLayout: CollectionViewLayout()) super.init(frame: frame, collectionViewLayout: CollectionViewLayout())
prepare()
} }
/// A convenience initializer that initializes the object. /// A convenience initializer that initializes the object.
public convenience init() { public init() {
self.init(frame: .zero) super.init(frame: .zero, collectionViewLayout: CollectionViewLayout())
prepare()
} }
/** /**
...@@ -131,5 +134,6 @@ open class CollectionView: UICollectionView { ...@@ -131,5 +134,6 @@ open class CollectionView: UICollectionView {
open func prepare() { open func prepare() {
backgroundColor = .white backgroundColor = .white
contentScaleFactor = Screen.scale contentScaleFactor = Screen.scale
register(CollectionViewCell.self, forCellWithReuseIdentifier: "CollectionViewCell")
} }
} }
...@@ -251,6 +251,7 @@ open class CollectionViewCell: UICollectionViewCell, Pulseable, PulseableLayer { ...@@ -251,6 +251,7 @@ open class CollectionViewCell: UICollectionViewCell, Pulseable, PulseableLayer {
when subclassing. when subclassing.
*/ */
open func prepare() { open func prepare() {
backgroundColor = .white
contentScaleFactor = Screen.scale contentScaleFactor = Screen.scale
prepareVisualLayer() prepareVisualLayer()
preparePulse() preparePulse()
......
...@@ -112,6 +112,7 @@ extension CollectionViewController { ...@@ -112,6 +112,7 @@ extension CollectionViewController {
} }
extension CollectionViewController: CollectionViewDelegate {} extension CollectionViewController: CollectionViewDelegate {}
extension CollectionViewController: CollectionViewDataSource { extension CollectionViewController: CollectionViewDataSource {
@objc @objc
open func numberOfSections(in collectionView: UICollectionView) -> Int { open func numberOfSections(in collectionView: UICollectionView) -> Int {
...@@ -125,6 +126,6 @@ extension CollectionViewController: CollectionViewDataSource { ...@@ -125,6 +126,6 @@ extension CollectionViewController: CollectionViewDataSource {
@objc @objc
open func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell { open func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
return UICollectionViewCell() return collectionView.dequeueReusableCell(withReuseIdentifier: "CollectionViewCell", for: indexPath)
} }
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment