Commit ca7be84e by Daniel Dahan

development: added layoutDivider to UIView extension and TableView defaults

parent 7c317d50
...@@ -260,7 +260,7 @@ open class Bar: View { ...@@ -260,7 +260,7 @@ open class Bar: View {
grid.commit() grid.commit()
contentView.grid.commit() contentView.grid.commit()
divider.reload() layoutDivider()
} }
/** /**
......
...@@ -101,7 +101,7 @@ open class BottomNavigationController: UITabBarController { ...@@ -101,7 +101,7 @@ open class BottomNavigationController: UITabBarController {
} }
} }
tabBar.divider.reload() tabBar.layoutDivider()
} }
/** /**
......
...@@ -101,7 +101,7 @@ open class BottomTabBar: UITabBar { ...@@ -101,7 +101,7 @@ open class BottomTabBar: UITabBar {
} }
} }
divider.reload() layoutDivider()
} }
open override func didMoveToSuperview() { open override func didMoveToSuperview() {
......
...@@ -122,7 +122,7 @@ open class CollectionView: UICollectionView { ...@@ -122,7 +122,7 @@ open class CollectionView: UICollectionView {
when subclassing. when subclassing.
*/ */
open func prepare() { open func prepare() {
contentScaleFactor = Screen.scale
backgroundColor = .white backgroundColor = .white
contentScaleFactor = Screen.scale
} }
} }
...@@ -212,4 +212,9 @@ extension UIView { ...@@ -212,4 +212,9 @@ extension UIView {
divider.thickness = value divider.thickness = value
} }
} }
/// Sets the divider frame.
open func layoutDivider() {
divider.reload()
}
} }
...@@ -148,7 +148,7 @@ open class NavigationBar: UINavigationBar { ...@@ -148,7 +148,7 @@ open class NavigationBar: UINavigationBar {
layoutNavigationItem(item: v) layoutNavigationItem(item: v)
} }
divider.reload() layoutDivider()
} }
open override func pushItem(_ item: UINavigationItem, animated: Bool) { open override func pushItem(_ item: UINavigationItem, animated: Bool) {
......
...@@ -268,7 +268,7 @@ open class TabBar: Bar { ...@@ -268,7 +268,7 @@ open class TabBar: Bar {
grid.commit() grid.commit()
contentView.grid.commit() contentView.grid.commit()
divider.reload() layoutDivider()
let buttonsWidth = buttons.reduce(0) { let buttonsWidth = buttons.reduce(0) {
$0 + $1.sizeThatFits(CGSize(width: .greatestFiniteMagnitude, height: contentView.height)).width + interimSpace $0 + $1.sizeThatFits(CGSize(width: .greatestFiniteMagnitude, height: contentView.height)).width + interimSpace
......
...@@ -30,4 +30,43 @@ ...@@ -30,4 +30,43 @@
import UIKit import UIKit
open class TableView: UITableView {} open class TableView: UITableView {
/**
An initializer that initializes the object with a NSCoder object.
- Parameter aDecoder: A NSCoder instance.
*/
public required init?(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
prepare()
}
public override init(frame: CGRect, style: UITableViewStyle) {
super.init(frame: frame, style: style)
prepare()
}
/**
An initializer that initializes the object.
- Parameter frame: A CGRect defining the view's frame.
*/
public convenience init(frame: CGRect) {
self.init(frame: frame, style: .plain)
}
/// A convenience initializer that initializes the object.
public convenience init() {
self.init(frame: .zero)
}
/**
Prepares the view instance when intialized. When subclassing,
it is recommended to override the prepare method
to initialize property values and other setup operations.
The super.prepare method should always be called immediately
when subclassing.
*/
open func prepare() {
backgroundColor = .white
contentScaleFactor = Screen.scale
}
}
...@@ -112,6 +112,7 @@ open class TableViewCell: UITableViewCell, Pulseable, PulseableLayer { ...@@ -112,6 +112,7 @@ open class TableViewCell: UITableViewCell, Pulseable, PulseableLayer {
layoutShape() layoutShape()
layoutVisualLayer() layoutVisualLayer()
layoutShadowPath() layoutShadowPath()
layoutDivider()
} }
/** /**
......
...@@ -528,11 +528,6 @@ extension TextField { ...@@ -528,11 +528,6 @@ extension TextField {
button?.frame = CGRect(x: width - height, y: 0, width: height, height: height) button?.frame = CGRect(x: width - height, y: 0, width: height, height: height)
} }
/// Layout the divider.
fileprivate func layoutDivider() {
divider.reload()
}
/// Layout the leftView. /// Layout the leftView.
fileprivate func layoutLeftView() { fileprivate func layoutLeftView() {
guard let v = leftView else { guard let v = leftView else {
......
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