Commit ca7be84e by Daniel Dahan

development: added layoutDivider to UIView extension and TableView defaults

parent 7c317d50
......@@ -260,7 +260,7 @@ open class Bar: View {
grid.commit()
contentView.grid.commit()
divider.reload()
layoutDivider()
}
/**
......
......@@ -101,7 +101,7 @@ open class BottomNavigationController: UITabBarController {
}
}
tabBar.divider.reload()
tabBar.layoutDivider()
}
/**
......
......@@ -101,7 +101,7 @@ open class BottomTabBar: UITabBar {
}
}
divider.reload()
layoutDivider()
}
open override func didMoveToSuperview() {
......
......@@ -121,8 +121,8 @@ open class CollectionView: UICollectionView {
The super.prepare method should always be called immediately
when subclassing.
*/
open func prepare() {
open func prepare() {
backgroundColor = .white
contentScaleFactor = Screen.scale
backgroundColor = .white
}
}
......@@ -212,4 +212,9 @@ extension UIView {
divider.thickness = value
}
}
/// Sets the divider frame.
open func layoutDivider() {
divider.reload()
}
}
......@@ -148,7 +148,7 @@ open class NavigationBar: UINavigationBar {
layoutNavigationItem(item: v)
}
divider.reload()
layoutDivider()
}
open override func pushItem(_ item: UINavigationItem, animated: Bool) {
......
......@@ -268,7 +268,7 @@ open class TabBar: Bar {
grid.commit()
contentView.grid.commit()
divider.reload()
layoutDivider()
let buttonsWidth = buttons.reduce(0) {
$0 + $1.sizeThatFits(CGSize(width: .greatestFiniteMagnitude, height: contentView.height)).width + interimSpace
......
......@@ -30,4 +30,43 @@
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 {
layoutShape()
layoutVisualLayer()
layoutShadowPath()
layoutDivider()
}
/**
......
......@@ -528,11 +528,6 @@ extension TextField {
button?.frame = CGRect(x: width - height, y: 0, width: height, height: height)
}
/// Layout the divider.
fileprivate func layoutDivider() {
divider.reload()
}
/// Layout the leftView.
fileprivate func layoutLeftView() {
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