Commit 2aa73721 by Daniel Dahan

samples issue-99: Fixed layout issues in CollectionView, where the sizing was…

samples issue-99: Fixed layout issues in CollectionView, where the sizing was not correctlly being initialized.
parent 6612bfd0
## 2.12.18
* Fixed layout issues in CollectionView, where the sizing was not correctlly being initialized.
## 2.12.17 ## 2.12.17
* [pr-979](https://github.com/CosmicMind/Material/pull/979): Added `visibilityOff` icon and updated `TextField` to utilize it. * [pr-979](https://github.com/CosmicMind/Material/pull/979): Added `visibilityOff` icon and updated `TextField` to utilize it.
......
...@@ -114,16 +114,14 @@ open class CollectionView: UICollectionView { ...@@ -114,16 +114,14 @@ open class CollectionView: UICollectionView {
- Parameter frame: A CGRect defining the view's frame. - Parameter frame: A CGRect defining the view's frame.
*/ */
public init(frame: CGRect) { public init(frame: CGRect) {
let layout = UICollectionViewFlowLayout() let layout = CollectionViewLayout()
layout.itemSize = CGSize(width: 100, height: 100)
super.init(frame: frame, collectionViewLayout: layout) super.init(frame: frame, collectionViewLayout: layout)
prepare() prepare()
} }
/// A convenience initializer that initializes the object. /// A convenience initializer that initializes the object.
public init() { public init() {
let layout = UICollectionViewFlowLayout() let layout = CollectionViewLayout()
layout.itemSize = CGSize(width: 100, height: 100)
super.init(frame: .zero, collectionViewLayout: layout) super.init(frame: .zero, collectionViewLayout: layout)
prepare() prepare()
} }
......
...@@ -99,7 +99,7 @@ extension CollectionViewController { ...@@ -99,7 +99,7 @@ extension CollectionViewController {
fileprivate func prepareCollectionView() { fileprivate func prepareCollectionView() {
collectionView.delegate = self collectionView.delegate = self
collectionView.dataSource = self collectionView.dataSource = self
view.addSubview(collectionView) view.layout(collectionView).edges()
} }
} }
......
...@@ -157,6 +157,7 @@ extension CollectionViewLayout { ...@@ -157,6 +157,7 @@ extension CollectionViewLayout {
attributes.frame = CGRect(x: contentEdgeInsets.left, y: offset.y, width: collectionView!.bounds.width - contentEdgeInsets.left - contentEdgeInsets.right, height: h) attributes.frame = CGRect(x: contentEdgeInsets.left, y: offset.y, width: collectionView!.bounds.width - contentEdgeInsets.left - contentEdgeInsets.right, height: h)
} else if let v = dataSourceItem.data as? UIView, 0 < v.bounds.height { } else if let v = dataSourceItem.data as? UIView, 0 < v.bounds.height {
v.updateConstraintsIfNeeded()
v.updateConstraints() v.updateConstraints()
v.setNeedsLayout() v.setNeedsLayout()
v.layoutIfNeeded() v.layoutIfNeeded()
...@@ -171,6 +172,7 @@ extension CollectionViewLayout { ...@@ -171,6 +172,7 @@ extension CollectionViewLayout {
attributes.frame = CGRect(x: offset.x, y: contentEdgeInsets.top, width: w, height: collectionView!.bounds.height - contentEdgeInsets.top - contentEdgeInsets.bottom) attributes.frame = CGRect(x: offset.x, y: contentEdgeInsets.top, width: w, height: collectionView!.bounds.height - contentEdgeInsets.top - contentEdgeInsets.bottom)
} else if let v = dataSourceItem.data as? UIView, 0 < v.bounds.width { } else if let v = dataSourceItem.data as? UIView, 0 < v.bounds.width {
v.updateConstraintsIfNeeded()
v.updateConstraints() v.updateConstraints()
v.setNeedsLayout() v.setNeedsLayout()
v.layoutIfNeeded() v.layoutIfNeeded()
......
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