Commit 365cba14 by Daniel Dahan

development: added convenience to CollectionView

parent ca7be84e
......@@ -102,11 +102,18 @@ open class CollectionView: UICollectionView {
/**
An initializer that initializes the object.
- Parameter collectionViewLayout: A UICollectionViewLayout reference.
*/
public convenience init(collectionViewLayout layout: UICollectionViewLayout) {
self.init(frame: .zero, collectionViewLayout: layout)
}
/**
An initializer that initializes the object.
- Parameter frame: A CGRect defining the view's frame.
*/
public init(frame: CGRect) {
super.init(frame: frame, collectionViewLayout: CollectionViewLayout())
prepare()
public convenience init(frame: CGRect) {
self.init(frame: frame, collectionViewLayout: CollectionViewLayout())
}
/// A convenience initializer that initializes the object.
......
......@@ -71,7 +71,7 @@ open class CollectionViewController: UIViewController {
open override func viewWillLayoutSubviews() {
super.viewWillLayoutSubviews()
collectionView.frame = view.bounds
layoutSubviews()
}
/**
......@@ -87,6 +87,11 @@ open class CollectionViewController: UIViewController {
view.contentScaleFactor = Screen.scale
prepareCollectionView()
}
/// Calls the layout functions for the view heirarchy.
open func layoutSubviews() {
layoutCollectionView()
}
}
extension CollectionViewController {
......@@ -95,6 +100,14 @@ extension CollectionViewController {
collectionView.delegate = self
collectionView.dataSource = self
view.addSubview(collectionView)
layoutCollectionView()
}
}
extension CollectionViewController {
/// Sets the frame for the collectionView.
fileprivate func layoutCollectionView() {
collectionView.frame = view.bounds
}
}
......
......@@ -108,8 +108,7 @@ open class NavigationController: UINavigationController {
open override func viewWillLayoutSubviews() {
super.viewWillLayoutSubviews()
navigationBar.setNeedsLayout()
navigationBar.layoutIfNeeded()
layoutSubviews()
}
/**
......@@ -133,6 +132,12 @@ open class NavigationController: UINavigationController {
v.delegate = self
}
}
/// Calls the layout functions for the view heirarchy.
open func layoutSubviews() {
navigationBar.setNeedsLayout()
navigationBar.layoutIfNeeded()
}
}
extension NavigationController: UINavigationBarDelegate {
......
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