Commit 68e44743 by Daniel Dahan

issue-845: removed name collisions. Closes #845.

parent 6598bb5b
...@@ -39,11 +39,11 @@ public enum ContentViewAlignment: Int { ...@@ -39,11 +39,11 @@ public enum ContentViewAlignment: Int {
open class Bar: View { open class Bar: View {
/// Will layout the view. /// Will layout the view.
open var willLayout: Bool { open var willLayout: Bool {
return 0 < width && 0 < height && nil != superview && !grid.deferred return 0 < bounds.width && 0 < bounds.height && nil != superview && !grid.deferred
} }
open override var intrinsicContentSize: CGSize { open override var intrinsicContentSize: CGSize {
return CGSize(width: width, height: height) return bounds.size
} }
/// Should center the contentView. /// Should center the contentView.
...@@ -195,9 +195,9 @@ open class Bar: View { ...@@ -195,9 +195,9 @@ open class Bar: View {
b.titleEdgeInsets = .zero b.titleEdgeInsets = .zero
} }
v.width = v.intrinsicContentSize.width v.frame.size.width = v.intrinsicContentSize.width
v.sizeToFit() v.sizeToFit()
v.grid.columns = Int(ceil(v.width / gridFactor)) + 2 v.grid.columns = Int(ceil(v.bounds.width / gridFactor)) + 2
lc += v.grid.columns lc += v.grid.columns
...@@ -212,9 +212,9 @@ open class Bar: View { ...@@ -212,9 +212,9 @@ open class Bar: View {
b.titleEdgeInsets = .zero b.titleEdgeInsets = .zero
} }
v.width = v.intrinsicContentSize.width v.frame.size.width = v.intrinsicContentSize.width
v.sizeToFit() v.sizeToFit()
v.grid.columns = Int(ceil(v.width / gridFactor)) + 2 v.grid.columns = Int(ceil(v.bounds.width / gridFactor)) + 2
rc += v.grid.columns rc += v.grid.columns
...@@ -237,7 +237,7 @@ open class Bar: View { ...@@ -237,7 +237,7 @@ open class Bar: View {
} }
} }
let p = width - l - r - contentEdgeInsets.left - contentEdgeInsets.right let p = bounds.width - l - r - contentEdgeInsets.left - contentEdgeInsets.right
let columns = Int(ceil(p / gridFactor)) let columns = Int(ceil(p / gridFactor))
if .center == contentViewAlignment { if .center == contentViewAlignment {
......
...@@ -291,6 +291,6 @@ extension Button { ...@@ -291,6 +291,6 @@ extension Button {
/// Manages the layout for the visualLayer property. /// Manages the layout for the visualLayer property.
fileprivate func layoutVisualLayer() { fileprivate func layoutVisualLayer() {
visualLayer.frame = bounds visualLayer.frame = bounds
visualLayer.cornerRadius = cornerRadius visualLayer.cornerRadius = layer.cornerRadius
} }
} }
...@@ -42,9 +42,12 @@ open class Card: PulseView { ...@@ -42,9 +42,12 @@ open class Card: PulseView {
} }
@IBInspectable @IBInspectable
open override var cornerRadius: CGFloat { open var cornerRadius: CGFloat {
didSet { get {
container.cornerRadius = cornerRadius return container.layer.cornerRadius
}
set(value) {
container.layer.cornerRadius = value
} }
} }
...@@ -177,7 +180,7 @@ open class Card: PulseView { ...@@ -177,7 +180,7 @@ open class Card: PulseView {
open override func layoutSubviews() { open override func layoutSubviews() {
super.layoutSubviews() super.layoutSubviews()
container.width = width container.frame.size.width = bounds.width
reload() reload()
} }
...@@ -197,7 +200,7 @@ open class Card: PulseView { ...@@ -197,7 +200,7 @@ open class Card: PulseView {
h = prepare(view: v, with: bottomBarEdgeInsets, from: h) h = prepare(view: v, with: bottomBarEdgeInsets, from: h)
} }
container.height = h container.frame.size.height = h
bounds.size.height = h bounds.size.height = h
} }
...@@ -220,19 +223,19 @@ open class Card: PulseView { ...@@ -220,19 +223,19 @@ open class Card: PulseView {
open func prepare(view: UIView, with insets: EdgeInsets, from top: CGFloat) -> CGFloat { open func prepare(view: UIView, with insets: EdgeInsets, from top: CGFloat) -> CGFloat {
let y = insets.top + top let y = insets.top + top
view.y = y view.frame.origin.y = y
view.x = insets.left view.frame.origin.x = insets.left
let w = container.width - insets.left - insets.right let w = container.bounds.width - insets.left - insets.right
var h = view.height var h = view.bounds.height
if 0 == h || nil != view as? UILabel { if 0 == h || nil != view as? UILabel {
(view as? UILabel)?.sizeToFit() (view as? UILabel)?.sizeToFit()
h = view.sizeThatFits(CGSize(width: w, height: .greatestFiniteMagnitude)).height h = view.sizeThatFits(CGSize(width: w, height: .greatestFiniteMagnitude)).height
} }
view.width = w view.frame.size.width = w
view.height = h view.frame.size.height = h
return y + h + insets.bottom return y + h + insets.bottom
} }
......
...@@ -62,7 +62,7 @@ fileprivate extension ChipItem { ...@@ -62,7 +62,7 @@ fileprivate extension ChipItem {
/// Lays out the chipItem based on its style. /// Lays out the chipItem based on its style.
func layoutChipItemStyle() { func layoutChipItemStyle() {
if .pill == chipItemStyle { if .pill == chipItemStyle {
cornerRadius = height / 2 layer.cornerRadius = bounds.height / 2
} }
} }
} }
...@@ -125,7 +125,7 @@ open class ChipBar: Bar { ...@@ -125,7 +125,7 @@ open class ChipBar: Bar {
let p = q + chipItemsInterimSpace let p = q + chipItemsInterimSpace
for v in chipItems { for v in chipItems {
let x = v.sizeThatFits(CGSize(width: .greatestFiniteMagnitude, height: scrollView.height)).width let x = v.sizeThatFits(CGSize(width: .greatestFiniteMagnitude, height: scrollView.bounds.height)).width
w += x w += x
w += p w += p
} }
...@@ -251,7 +251,7 @@ fileprivate extension ChipBar { ...@@ -251,7 +251,7 @@ fileprivate extension ChipBar {
func prepareChipItems() { func prepareChipItems() {
for v in chipItems { for v in chipItems {
v.grid.columns = 0 v.grid.columns = 0
v.cornerRadius = 0 v.layer.cornerRadius = 0
v.contentEdgeInsets = .zero v.contentEdgeInsets = .zero
v.removeTarget(self, action: #selector(handle(chipItem:)), for: .touchUpInside) v.removeTarget(self, action: #selector(handle(chipItem:)), for: .touchUpInside)
...@@ -261,7 +261,7 @@ fileprivate extension ChipBar { ...@@ -261,7 +261,7 @@ fileprivate extension ChipBar {
/// Prepares the contentView. /// Prepares the contentView.
func prepareContentView() { func prepareContentView() {
contentView.zPosition = 6000 contentView.layer.zPosition = 6000
} }
/// Prepares the scroll view. /// Prepares the scroll view.
...@@ -277,16 +277,16 @@ fileprivate extension ChipBar { ...@@ -277,16 +277,16 @@ fileprivate extension ChipBar {
func layoutScrollView() { func layoutScrollView() {
contentView.grid.reload() contentView.grid.reload()
if .scrollable == chipBarStyle || (.auto == chipBarStyle && chipItemsTotalWidth > scrollView.width) { if .scrollable == chipBarStyle || (.auto == chipBarStyle && chipItemsTotalWidth > scrollView.bounds.width) {
var w: CGFloat = 0 var w: CGFloat = 0
let q = 2 * chipItemsInterimSpace let q = 2 * chipItemsInterimSpace
let p = q + chipItemsInterimSpace let p = q + chipItemsInterimSpace
for v in chipItems { for v in chipItems {
let x = v.sizeThatFits(CGSize(width: .greatestFiniteMagnitude, height: scrollView.height)).width let x = v.sizeThatFits(CGSize(width: .greatestFiniteMagnitude, height: scrollView.bounds.height)).width
v.height = scrollView.height v.frame.size.height = scrollView.bounds.height
v.width = x + q v.frame.size.width = x + q
v.x = w v.frame.origin.x = w
w += x w += x
w += p w += p
...@@ -298,7 +298,7 @@ fileprivate extension ChipBar { ...@@ -298,7 +298,7 @@ fileprivate extension ChipBar {
w -= chipItemsInterimSpace w -= chipItemsInterimSpace
scrollView.contentSize = CGSize(width: w, height: scrollView.height) scrollView.contentSize = CGSize(width: w, height: scrollView.bounds.height)
} else { } else {
scrollView.grid.begin() scrollView.grid.begin()
...@@ -370,7 +370,7 @@ fileprivate extension ChipBar { ...@@ -370,7 +370,7 @@ fileprivate extension ChipBar {
} }
if !scrollView.bounds.contains(v.frame) { if !scrollView.bounds.contains(v.frame) {
let contentOffsetX = (v.x < scrollView.bounds.minX) ? v.x : v.frame.maxX - scrollView.bounds.width let contentOffsetX = (v.frame.origin.x < scrollView.bounds.minX) ? v.frame.origin.x : v.frame.maxX - scrollView.bounds.width
let normalizedOffsetX = min(max(contentOffsetX, 0), scrollView.contentSize.width - scrollView.bounds.width) let normalizedOffsetX = min(max(contentOffsetX, 0), scrollView.contentSize.width - scrollView.bounds.width)
scrollView.setContentOffset(CGPoint(x: normalizedOffsetX, y: 0), animated: true) scrollView.setContentOffset(CGPoint(x: normalizedOffsetX, y: 0), animated: true)
} }
......
...@@ -97,26 +97,26 @@ fileprivate extension ChipBarController { ...@@ -97,26 +97,26 @@ fileprivate extension ChipBarController {
fileprivate extension ChipBarController { fileprivate extension ChipBarController {
/// Layout the container. /// Layout the container.
func layoutContainer() { func layoutContainer() {
chipBar.width = view.width chipBar.frame.size.width = view.bounds.width
switch displayStyle { switch displayStyle {
case .partial: case .partial:
let p = chipBar.height let p = chipBar.bounds.height
let y = view.height - p let y = view.bounds.height - p
switch chipBarAlignment { switch chipBarAlignment {
case .top: case .top:
container.y = p container.frame.origin.y = p
container.height = y container.frame.size.height = y
case .bottom: case .bottom:
container.y = 0 container.frame.origin.y = 0
container.height = y container.frame.size.height = y
case .hidden: case .hidden:
container.y = 0 container.frame.origin.y = 0
container.height = view.height container.frame.size.height = view.bounds.height
} }
container.width = view.width container.frame.size.width = view.bounds.width
case .full: case .full:
container.frame = view.bounds container.frame = view.bounds
...@@ -125,15 +125,15 @@ fileprivate extension ChipBarController { ...@@ -125,15 +125,15 @@ fileprivate extension ChipBarController {
/// Layout the chipBar. /// Layout the chipBar.
func layoutChipBar() { func layoutChipBar() {
chipBar.width = view.width chipBar.frame.size.width = view.bounds.width
switch chipBarAlignment { switch chipBarAlignment {
case .top: case .top:
chipBar.isHidden = false chipBar.isHidden = false
chipBar.y = 0 chipBar.frame.origin.y = 0
case .bottom: case .bottom:
chipBar.isHidden = false chipBar.isHidden = false
chipBar.y = view.height - chipBar.height chipBar.frame.origin.y = view.bounds.height - chipBar.bounds.height
case .hidden: case .hidden:
chipBar.isHidden = true chipBar.isHidden = true
} }
......
...@@ -317,6 +317,6 @@ extension CollectionReusableView { ...@@ -317,6 +317,6 @@ extension CollectionReusableView {
/// Manages the layout for the visualLayer property. /// Manages the layout for the visualLayer property.
fileprivate func layoutVisualLayer() { fileprivate func layoutVisualLayer() {
visualLayer.frame = bounds visualLayer.frame = bounds
visualLayer.cornerRadius = cornerRadius visualLayer.cornerRadius = layer.cornerRadius
} }
} }
...@@ -276,6 +276,6 @@ extension CollectionViewCell { ...@@ -276,6 +276,6 @@ extension CollectionViewCell {
/// Manages the layout for the visualLayer property. /// Manages the layout for the visualLayer property.
fileprivate func layoutVisualLayer() { fileprivate func layoutVisualLayer() {
visualLayer.frame = bounds visualLayer.frame = bounds
visualLayer.cornerRadius = cornerRadius visualLayer.cornerRadius = layer.cornerRadius
} }
} }
...@@ -79,7 +79,7 @@ public struct Divider { ...@@ -79,7 +79,7 @@ public struct Divider {
} }
if nil == line { if nil == line {
line = UIView() line = UIView()
line?.zPosition = 5000 line?.layer.zPosition = 5000
view?.addSubview(line!) view?.addSubview(line!)
reload() reload()
} }
...@@ -123,13 +123,13 @@ public struct Divider { ...@@ -123,13 +123,13 @@ public struct Divider {
switch alignment { switch alignment {
case .top: case .top:
l.frame = CGRect(x: c.left, y: c.top, width: v.width - c.left - c.right, height: thickness) l.frame = CGRect(x: c.left, y: c.top, width: v.bounds.width - c.left - c.right, height: thickness)
case .bottom: case .bottom:
l.frame = CGRect(x: c.left, y: v.height - thickness - c.bottom, width: v.width - c.left - c.right, height: thickness) l.frame = CGRect(x: c.left, y: v.bounds.height - thickness - c.bottom, width: v.bounds.width - c.left - c.right, height: thickness)
case .left: case .left:
l.frame = CGRect(x: c.left, y: c.top, width: thickness, height: v.height - c.top - c.bottom) l.frame = CGRect(x: c.left, y: c.top, width: thickness, height: v.bounds.height - c.top - c.bottom)
case .right: case .right:
l.frame = CGRect(x: v.width - thickness - c.right, y: c.top, width: thickness, height: v.height - c.top - c.bottom) l.frame = CGRect(x: v.bounds.width - thickness - c.right, y: c.top, width: thickness, height: v.bounds.height - c.top - c.bottom)
} }
} }
} }
......
...@@ -92,15 +92,15 @@ extension FABMenuItem { ...@@ -92,15 +92,15 @@ extension FABMenuItem {
let interimSpace = InterimSpacePresetToValue(preset: .interimSpace6) let interimSpace = InterimSpacePresetToValue(preset: .interimSpace6)
titleLabel.sizeToFit() titleLabel.sizeToFit()
titleLabel.width += 1.5 * interimSpace titleLabel.frame.size.width += 1.5 * interimSpace
titleLabel.height += interimSpace / 2 titleLabel.frame.size.height += interimSpace / 2
titleLabel.y = (height - titleLabel.height) / 2 titleLabel.frame.origin.y = (bounds.height - titleLabel.bounds.height) / 2
switch titleLabelPosition { switch titleLabelPosition {
case .left: case .left:
titleLabel.x = -titleLabel.width - interimSpace titleLabel.frame.origin.x = -titleLabel.bounds.width - interimSpace
case .right: case .right:
titleLabel.x = frame.width + interimSpace titleLabel.frame.origin.x = frame.bounds.width + interimSpace
} }
titleLabel.alpha = 0 titleLabel.alpha = 0
......
...@@ -74,11 +74,11 @@ open class FABMenuController: TransitionController { ...@@ -74,11 +74,11 @@ open class FABMenuController: TransitionController {
extension FABMenuController: FABMenuDelegate {} extension FABMenuController: FABMenuDelegate {}
extension FABMenuController { fileprivate extension FABMenuController {
/// Prepares the fabMenu. /// Prepares the fabMenu.
fileprivate func prepareFABMenu() { func prepareFABMenu() {
fabMenu.delegate = self fabMenu.delegate = self
fabMenu.zPosition = 1000 fabMenu.layer.zPosition = 1000
fabMenu.handleFABButtonCallback = { [weak self] in fabMenu.handleFABButtonCallback = { [weak self] in
self?.handleFABButtonCallback(button: $0) self?.handleFABButtonCallback(button: $0)
......
...@@ -210,7 +210,7 @@ public struct Grid { ...@@ -210,7 +210,7 @@ public struct Grid {
return return
} }
guard 0 < canvas.width && 0 < canvas.height else { guard 0 < canvas.bounds.width && 0 < canvas.bounds.height else {
return return
} }
...@@ -227,10 +227,10 @@ public struct Grid { ...@@ -227,10 +227,10 @@ public struct Grid {
let co = v.grid.offset.columns let co = v.grid.offset.columns
let w = (canvas.bounds.width - contentEdgeInsets.left - contentEdgeInsets.right - layoutEdgeInsets.left - layoutEdgeInsets.right + interimSpace) / CGFloat(axis.columns) let w = (canvas.bounds.width - contentEdgeInsets.left - contentEdgeInsets.right - layoutEdgeInsets.left - layoutEdgeInsets.right + interimSpace) / CGFloat(axis.columns)
v.x = CGFloat(i + n + co) * w + contentEdgeInsets.left + layoutEdgeInsets.left v.frame.origin.x = CGFloat(i + n + co) * w + contentEdgeInsets.left + layoutEdgeInsets.left
v.y = contentEdgeInsets.top + layoutEdgeInsets.top v.frame.origin.y = contentEdgeInsets.top + layoutEdgeInsets.top
v.width = w * CGFloat(c) - interimSpace v.frame.size.width = w * CGFloat(c) - interimSpace
v.height = canvas.bounds.height - contentEdgeInsets.top - contentEdgeInsets.bottom - layoutEdgeInsets.top - layoutEdgeInsets.bottom v.frame.size.height = canvas.bounds.height - contentEdgeInsets.top - contentEdgeInsets.bottom - layoutEdgeInsets.top - layoutEdgeInsets.bottom
n += c + co - 1 n += c + co - 1
...@@ -239,10 +239,10 @@ public struct Grid { ...@@ -239,10 +239,10 @@ public struct Grid {
let ro = v.grid.offset.rows let ro = v.grid.offset.rows
let h = (canvas.bounds.height - contentEdgeInsets.top - contentEdgeInsets.bottom - layoutEdgeInsets.top - layoutEdgeInsets.bottom + interimSpace) / CGFloat(axis.rows) let h = (canvas.bounds.height - contentEdgeInsets.top - contentEdgeInsets.bottom - layoutEdgeInsets.top - layoutEdgeInsets.bottom + interimSpace) / CGFloat(axis.rows)
v.x = contentEdgeInsets.left + layoutEdgeInsets.left v.frame.origin.x = contentEdgeInsets.left + layoutEdgeInsets.left
v.y = CGFloat(i + n + ro) * h + contentEdgeInsets.top + layoutEdgeInsets.top v.frame.origin.y = CGFloat(i + n + ro) * h + contentEdgeInsets.top + layoutEdgeInsets.top
v.width = canvas.bounds.width - contentEdgeInsets.left - contentEdgeInsets.right - layoutEdgeInsets.left - layoutEdgeInsets.right v.frame.size.width = canvas.bounds.width - contentEdgeInsets.left - contentEdgeInsets.right - layoutEdgeInsets.left - layoutEdgeInsets.right
v.height = h * CGFloat(r) - interimSpace v.frame.size.height = h * CGFloat(r) - interimSpace
n += r + ro - 1 n += r + ro - 1
...@@ -254,10 +254,10 @@ public struct Grid { ...@@ -254,10 +254,10 @@ public struct Grid {
let w = (canvas.bounds.width - contentEdgeInsets.left - contentEdgeInsets.right - layoutEdgeInsets.left - layoutEdgeInsets.right + interimSpace) / CGFloat(axis.columns) let w = (canvas.bounds.width - contentEdgeInsets.left - contentEdgeInsets.right - layoutEdgeInsets.left - layoutEdgeInsets.right + interimSpace) / CGFloat(axis.columns)
let h = (canvas.bounds.height - contentEdgeInsets.top - contentEdgeInsets.bottom - layoutEdgeInsets.top - layoutEdgeInsets.bottom + interimSpace) / CGFloat(axis.rows) let h = (canvas.bounds.height - contentEdgeInsets.top - contentEdgeInsets.bottom - layoutEdgeInsets.top - layoutEdgeInsets.bottom + interimSpace) / CGFloat(axis.rows)
v.x = CGFloat(co) * w + contentEdgeInsets.left + layoutEdgeInsets.left v.frame.origin.x = CGFloat(co) * w + contentEdgeInsets.left + layoutEdgeInsets.left
v.y = CGFloat(ro) * h + contentEdgeInsets.top + layoutEdgeInsets.top v.frame.origin.y = CGFloat(ro) * h + contentEdgeInsets.top + layoutEdgeInsets.top
v.width = w * CGFloat(c) - interimSpace v.frame.size.width = w * CGFloat(c) - interimSpace
v.height = h * CGFloat(r) - interimSpace v.frame.size.height = h * CGFloat(r) - interimSpace
} }
i += 1 i += 1
......
...@@ -87,7 +87,7 @@ open class ImageCard: Card { ...@@ -87,7 +87,7 @@ open class ImageCard: Card {
if let v = toolbar { if let v = toolbar {
prepare(view: v, with: toolbarEdgeInsets, from: h) prepare(view: v, with: toolbarEdgeInsets, from: h)
v.y = .top == toolbarAlignment ? toolbarEdgeInsets.top : h - v.height - toolbarEdgeInsets.bottom v.frame.origin.y = .top == toolbarAlignment ? toolbarEdgeInsets.top : h - v.bounds.height - toolbarEdgeInsets.bottom
container.bringSubview(toFront: v) container.bringSubview(toFront: v)
} }
...@@ -99,7 +99,7 @@ open class ImageCard: Card { ...@@ -99,7 +99,7 @@ open class ImageCard: Card {
h = prepare(view: v, with: bottomBarEdgeInsets, from: h) h = prepare(view: v, with: bottomBarEdgeInsets, from: h)
} }
container.height = h container.frame.size.height = h
bounds.size.height = h bounds.size.height = h
} }
} }
...@@ -31,80 +31,30 @@ ...@@ -31,80 +31,30 @@
import UIKit import UIKit
extension UIView { extension UIView {
/// A property that accesses the backing layer's masksToBounds. /// A property that accesses the backing layer's shadow
@IBInspectable open var shadowColor: UIColor? {
open var masksToBounds: Bool {
get {
return layer.masksToBounds
}
set(value) {
layer.masksToBounds = value
}
}
/// A property that accesses the backing layer's opacity.
@IBInspectable
open var opacity: Float {
get {
return layer.opacity
}
set(value) {
layer.opacity = value
}
}
/// A property that accesses the backing layer's anchorPoint.
@IBInspectable
open var anchorPoint: CGPoint {
get {
return layer.anchorPoint
}
set(value) {
layer.anchorPoint = value
}
}
/// A property that accesses the frame.origin.x property.
@IBInspectable
open var x: CGFloat {
get {
return layer.x
}
set(value) {
layer.x = value
}
}
/// A property that accesses the frame.origin.y property.
@IBInspectable
open var y: CGFloat {
get {
return layer.y
}
set(value) {
layer.y = value
}
}
/// A property that accesses the frame.size.width property.
@IBInspectable
open var width: CGFloat {
get { get {
return layer.width guard let v = layer.shadowColor else {
return nil
}
return UIColor(cgColor: v)
} }
set(value) { set(value) {
layer.width = value layer.shadowColor = value?.cgColor
} }
} }
/// A property that accesses the frame.size.height property. /// A property that accesses the layer.borderColor property.
@IBInspectable open var borderColor: UIColor? {
open var height: CGFloat {
get { get {
return layer.height guard let v = layer.borderColor else {
return nil
}
return UIColor(cgColor: v)
} }
set(value) { set(value) {
layer.height = value layer.borderColor = value?.cgColor
} }
} }
...@@ -153,65 +103,6 @@ extension UIView { ...@@ -153,65 +103,6 @@ extension UIView {
} }
} }
/// A property that accesses the backing layer's shadow
@IBInspectable
open var shadowColor: UIColor? {
get {
guard let v = layer.shadowColor else {
return nil
}
return UIColor(cgColor: v)
}
set(value) {
layer.shadowColor = value?.cgColor
}
}
/// A property that accesses the backing layer's shadowOffset.
@IBInspectable
open var shadowOffset: CGSize {
get {
return layer.shadowOffset
}
set(value) {
layer.shadowOffset = value
}
}
/// A property that accesses the backing layer's shadowOpacity.
@IBInspectable
open var shadowOpacity: Float {
get {
return layer.shadowOpacity
}
set(value) {
layer.shadowOpacity = value
}
}
/// A property that accesses the backing layer's shadowRadius.
@IBInspectable
open var shadowRadius: CGFloat {
get {
return layer.shadowRadius
}
set(value) {
layer.shadowRadius = value
}
}
/// A property that accesses the backing layer's shadowPath.
@IBInspectable
open var shadowPath: CGPath? {
get {
return layer.shadowPath
}
set(value) {
layer.shadowPath = value
}
}
/// Enables automatic shadowPath sizing. /// Enables automatic shadowPath sizing.
@IBInspectable @IBInspectable
open var isShadowPathAutoSizing: Bool { open var isShadowPathAutoSizing: Bool {
...@@ -234,17 +125,6 @@ extension UIView { ...@@ -234,17 +125,6 @@ extension UIView {
} }
} }
/// A property that accesses the layer.cornerRadius.
@IBInspectable
open var cornerRadius: CGFloat {
get {
return layer.cornerRadius
}
set(value) {
layer.cornerRadius = value
}
}
/// A preset property to set the borderWidth. /// A preset property to set the borderWidth.
open var borderWidthPreset: BorderWidthPreset { open var borderWidthPreset: BorderWidthPreset {
get { get {
...@@ -254,61 +134,16 @@ extension UIView { ...@@ -254,61 +134,16 @@ extension UIView {
layer.borderWidthPreset = value layer.borderWidthPreset = value
} }
} }
}
/// A property that accesses the layer.borderWith.
@IBInspectable extension UIView {
open var borderWidth: CGFloat {
get {
return layer.borderWidth
}
set(value) {
layer.borderWidth = value
}
}
/// A property that accesses the layer.borderColor property.
@IBInspectable
open var borderColor: UIColor? {
get {
guard let v = layer.borderColor else {
return nil
}
return UIColor(cgColor: v)
}
set(value) {
layer.borderColor = value?.cgColor
}
}
/// A property that accesses the layer.position property.
@IBInspectable
open var position: CGPoint {
get {
return layer.position
}
set(value) {
layer.position = value
}
}
/// A property that accesses the layer.zPosition property.
@IBInspectable
open var zPosition: CGFloat {
get {
return layer.zPosition
}
set(value) {
layer.zPosition = value
}
}
/// Manages the layout for the shape of the view instance. /// Manages the layout for the shape of the view instance.
open func layoutShape() { internal func layoutShape() {
layer.layoutShape() layer.layoutShape()
} }
/// Sets the shadow path. /// Sets the shadow path.
open func layoutShadowPath() { internal func layoutShadowPath() {
layer.layoutShadowPath() layer.layoutShadowPath()
} }
} }
...@@ -33,11 +33,11 @@ import UIKit ...@@ -33,11 +33,11 @@ import UIKit
open class NavigationBar: UINavigationBar { open class NavigationBar: UINavigationBar {
/// Will layout the view. /// Will layout the view.
open var willLayout: Bool { open var willLayout: Bool {
return 0 < width && 0 < height && nil != superview return 0 < bounds.width && 0 < bounds.height && nil != superview
} }
open override var intrinsicContentSize: CGSize { open override var intrinsicContentSize: CGSize {
return CGSize(width: width, height: height) return CGSize(width: bounds.width, height: bounds.height)
} }
/// A preset wrapper around contentEdgeInsets. /// A preset wrapper around contentEdgeInsets.
...@@ -183,9 +183,9 @@ open class NavigationBar: UINavigationBar { ...@@ -183,9 +183,9 @@ open class NavigationBar: UINavigationBar {
b.titleEdgeInsets = .zero b.titleEdgeInsets = .zero
} }
v.width = v.intrinsicContentSize.width v.frame.size.width = v.intrinsicContentSize.width
v.sizeToFit() v.sizeToFit()
v.grid.columns = Int(ceil(v.width / gridFactor)) + 2 v.grid.columns = Int(ceil(v.bounds.width / gridFactor)) + 2
lc += v.grid.columns lc += v.grid.columns
...@@ -200,9 +200,9 @@ open class NavigationBar: UINavigationBar { ...@@ -200,9 +200,9 @@ open class NavigationBar: UINavigationBar {
b.titleEdgeInsets = .zero b.titleEdgeInsets = .zero
} }
v.width = v.intrinsicContentSize.width v.frame.size.width = v.intrinsicContentSize.width
v.sizeToFit() v.sizeToFit()
v.grid.columns = Int(ceil(v.width / gridFactor)) + 2 v.grid.columns = Int(ceil(v.bounds.width / gridFactor)) + 2
rc += v.grid.columns rc += v.grid.columns
...@@ -225,7 +225,7 @@ open class NavigationBar: UINavigationBar { ...@@ -225,7 +225,7 @@ open class NavigationBar: UINavigationBar {
} }
} }
let p = width - l - r - contentEdgeInsets.left - contentEdgeInsets.right let p = bounds.width - l - r - contentEdgeInsets.left - contentEdgeInsets.right
let columns = Int(ceil(p / gridFactor)) let columns = Int(ceil(p / gridFactor))
if .center == item.contentViewAlignment { if .center == item.contentViewAlignment {
...@@ -267,14 +267,14 @@ open class NavigationBar: UINavigationBar { ...@@ -267,14 +267,14 @@ open class NavigationBar: UINavigationBar {
item.titleLabel.sizeToFit() item.titleLabel.sizeToFit()
item.detailLabel.sizeToFit() item.detailLabel.sizeToFit()
let diff = (item.contentView.height - item.titleLabel.height - item.detailLabel.height) / 2 let diff = (item.contentView.bounds.height - item.titleLabel.bounds.height - item.detailLabel.bounds.height) / 2
item.titleLabel.height += diff item.titleLabel.frame.size.height += diff
item.titleLabel.width = item.contentView.width item.titleLabel.frame.size.width = item.contentView.bounds.width
item.detailLabel.height += diff item.detailLabel.frame.size.height += diff
item.detailLabel.width = item.contentView.width item.detailLabel.frame.size.width = item.contentView.bounds.width
item.detailLabel.y = item.titleLabel.height item.detailLabel.frame.origin.y = item.titleLabel.bounds.height
} }
} else { } else {
item.detailLabel.removeFromSuperview() item.detailLabel.removeFromSuperview()
......
...@@ -120,7 +120,7 @@ open class NavigationController: UINavigationController { ...@@ -120,7 +120,7 @@ open class NavigationController: UINavigationController {
*/ */
open func prepare() { open func prepare() {
navigationBar.heightPreset = .normal navigationBar.heightPreset = .normal
navigationBar.width = view.width navigationBar.frame.size.width = view.bounds.width
view.clipsToBounds = true view.clipsToBounds = true
view.backgroundColor = .white view.backgroundColor = .white
......
...@@ -78,7 +78,7 @@ open class PresenterCard: Card { ...@@ -78,7 +78,7 @@ open class PresenterCard: Card {
h = prepare(view: v, with: bottomBarEdgeInsets, from: h) h = prepare(view: v, with: bottomBarEdgeInsets, from: h)
} }
container.height = h container.frame.size.height = h
bounds.size.height = h bounds.size.height = h
} }
} }
...@@ -77,7 +77,7 @@ open class SearchBarController: StatusBarController { ...@@ -77,7 +77,7 @@ open class SearchBarController: StatusBarController {
fileprivate extension SearchBarController { fileprivate extension SearchBarController {
/// Prepares the searchBar. /// Prepares the searchBar.
func prepareSearchBar() { func prepareSearchBar() {
searchBar.zPosition = 1000 searchBar.layer.zPosition = 1000
searchBar.depthPreset = .depth1 searchBar.depthPreset = .depth1
view.addSubview(searchBar) view.addSubview(searchBar)
} }
...@@ -88,20 +88,20 @@ fileprivate extension SearchBarController { ...@@ -88,20 +88,20 @@ fileprivate extension SearchBarController {
func layoutContainer() { func layoutContainer() {
switch displayStyle { switch displayStyle {
case .partial: case .partial:
let p = searchBar.height let p = searchBar.bounds.height
let q = statusBarOffsetAdjustment let q = statusBarOffsetAdjustment
let h = view.height - p - q let h = view.bounds.height - p - q
switch searchBarAlignment { switch searchBarAlignment {
case .top: case .top:
container.y = q + p container.frame.origin.y = q + p
container.height = h container.frame.size.height = h
case .bottom: case .bottom:
container.y = q container.frame.origin.y = q
container.height = h container.frame.size.height = h
} }
container.width = view.width container.frame.size.width = view.bounds.width
case .full: case .full:
container.frame = view.bounds container.frame = view.bounds
...@@ -110,9 +110,9 @@ fileprivate extension SearchBarController { ...@@ -110,9 +110,9 @@ fileprivate extension SearchBarController {
/// Layout the searchBar. /// Layout the searchBar.
func layoutSearchBar() { func layoutSearchBar() {
searchBar.x = 0 searchBar.frame.origin.x = 0
searchBar.y = .top == searchBarAlignment ? statusBarOffsetAdjustment : view.height - searchBar.height searchBar.frame.origin.y = .top == searchBarAlignment ? statusBarOffsetAdjustment : view.bounds.height - searchBar.bounds.height
searchBar.width = view.width searchBar.frame.size.width = view.bounds.width
} }
/// Layout the rootViewController. /// Layout the rootViewController.
......
...@@ -64,7 +64,7 @@ open class Snackbar: Bar { ...@@ -64,7 +64,7 @@ open class Snackbar: Bar {
open let textLabel = UILabel() open let textLabel = UILabel()
open override var intrinsicContentSize: CGSize { open override var intrinsicContentSize: CGSize {
return CGSize(width: width, height: 49) return CGSize(width: bounds.width, height: 49)
} }
/// The status of the snackbar. /// The status of the snackbar.
......
...@@ -175,8 +175,8 @@ open class SnackbarController: TransitionController { ...@@ -175,8 +175,8 @@ open class SnackbarController: TransitionController {
/// Reloads the view. /// Reloads the view.
open func reload() { open func reload() {
snackbar.x = snackbarEdgeInsets.left snackbar.frame.origin.x = snackbarEdgeInsets.left
snackbar.width = view.width - snackbarEdgeInsets.left - snackbarEdgeInsets.right snackbar.frame.size.width = view.bounds.width - snackbarEdgeInsets.left - snackbarEdgeInsets.right
rootViewController.view.frame = view.bounds rootViewController.view.frame = view.bounds
layoutSnackbar(status: snackbar.status) layoutSnackbar(status: snackbar.status)
} }
...@@ -188,7 +188,7 @@ open class SnackbarController: TransitionController { ...@@ -188,7 +188,7 @@ open class SnackbarController: TransitionController {
/// Prepares the snackbar. /// Prepares the snackbar.
private func prepareSnackbar() { private func prepareSnackbar() {
snackbar.zPosition = 10000 snackbar.layer.zPosition = 10000
view.addSubview(snackbar) view.addSubview(snackbar)
} }
...@@ -198,9 +198,9 @@ open class SnackbarController: TransitionController { ...@@ -198,9 +198,9 @@ open class SnackbarController: TransitionController {
*/ */
private func layoutSnackbar(status: SnackbarStatus) { private func layoutSnackbar(status: SnackbarStatus) {
if .bottom == snackbarAlignment { if .bottom == snackbarAlignment {
snackbar.y = .visible == status ? view.height - snackbar.height - snackbarEdgeInsets.bottom : view.height snackbar.frame.origin.y = .visible == status ? view.bounds.height - snackbar.bounds.height - snackbarEdgeInsets.bottom : view.bounds.height
} else { } else {
snackbar.y = .visible == status ? snackbarEdgeInsets.top : -snackbar.height snackbar.frame.origin.y = .visible == status ? snackbarEdgeInsets.top : -snackbar.bounds.height
} }
} }
} }
...@@ -92,9 +92,9 @@ open class SpringAnimation { ...@@ -92,9 +92,9 @@ open class SpringAnimation {
v.alpha = 0 v.alpha = 0
v.isHidden = true v.isHidden = true
v.frame.size = itemSize v.frame.size = itemSize
v.x = (baseSize.width - itemSize.width) / 2 v.frame.origin.x = (baseSize.width - itemSize.width) / 2
v.y = (baseSize.height - itemSize.height) / 2 v.frame.origin.y = (baseSize.height - itemSize.height) / 2
v.zPosition = CGFloat(10000 - views.count - i) v.layer.zPosition = CGFloat(10000 - views.count - i)
} }
} }
} }
...@@ -238,7 +238,7 @@ extension SpringAnimation { ...@@ -238,7 +238,7 @@ extension SpringAnimation {
options: options, options: options,
animations: { [s = interimSpace, m = CGFloat(i + 1), v = v] in animations: { [s = interimSpace, m = CGFloat(i + 1), v = v] in
v.alpha = 1 v.alpha = 1
v.y = -m * (v.height + s) v.frame.origin.y = -m * (v.bounds.height + s)
animations?(v) animations?(v)
}) { [weak self, v = v] _ in }) { [weak self, v = v] _ in
self?.handleOpenCompletion(view: v, completion: completion) self?.handleOpenCompletion(view: v, completion: completion)
...@@ -267,7 +267,7 @@ extension SpringAnimation { ...@@ -267,7 +267,7 @@ extension SpringAnimation {
options: options, options: options,
animations: { [v = v] in animations: { [v = v] in
v.alpha = 0 v.alpha = 0
v.y = 0 v.frame.origin.y = 0
animations?(v) animations?(v)
}) { [weak self, v = v] _ in }) { [weak self, v = v] _ in
self?.handleCloseCompletion(view: v, completion: completion) self?.handleCloseCompletion(view: v, completion: completion)
...@@ -298,7 +298,7 @@ extension SpringAnimation { ...@@ -298,7 +298,7 @@ extension SpringAnimation {
options: options, options: options,
animations: { [s = interimSpace, m = CGFloat(i + 1), v = v] in animations: { [s = interimSpace, m = CGFloat(i + 1), v = v] in
v.alpha = 1 v.alpha = 1
v.y = m * (v.height + s) v.frame.origin.y = m * (v.bounds.height + s)
animations?(v) animations?(v)
}) { [weak self, v = v] _ in }) { [weak self, v = v] _ in
...@@ -332,7 +332,7 @@ extension SpringAnimation { ...@@ -332,7 +332,7 @@ extension SpringAnimation {
options: options, options: options,
animations: { [first = first, v = v] in animations: { [first = first, v = v] in
v.alpha = 0 v.alpha = 0
v.y = first.y v.frame.origin.y = first.frame.origin.y
animations?(v) animations?(v)
}) { [weak self, v = v] _ in }) { [weak self, v = v] _ in
...@@ -364,7 +364,7 @@ extension SpringAnimation { ...@@ -364,7 +364,7 @@ extension SpringAnimation {
options: options, options: options,
animations: { [s = interimSpace, m = CGFloat(i + 1), v = v] in animations: { [s = interimSpace, m = CGFloat(i + 1), v = v] in
v.alpha = 1 v.alpha = 1
v.x = -m * (v.width + s) v.frame.origin.x = -m * (v.bounds.width + s)
animations?(v) animations?(v)
}) { [weak self, v = v] _ in }) { [weak self, v = v] _ in
...@@ -398,7 +398,7 @@ extension SpringAnimation { ...@@ -398,7 +398,7 @@ extension SpringAnimation {
options: options, options: options,
animations: { [first = first, v = v] in animations: { [first = first, v = v] in
v.alpha = 0 v.alpha = 0
v.x = first.x v.frame.origin.x = first.frame.origin.x
animations?(v) animations?(v)
}) { [weak self, v = v] _ in }) { [weak self, v = v] _ in
...@@ -430,7 +430,7 @@ extension SpringAnimation { ...@@ -430,7 +430,7 @@ extension SpringAnimation {
options: options, options: options,
animations: { [s = interimSpace, m = CGFloat(i + 1), v = v] in animations: { [s = interimSpace, m = CGFloat(i + 1), v = v] in
v.alpha = 1 v.alpha = 1
v.x = m * (v.width + s) v.frame.origin.x = m * (v.bounds.width + s)
animations?(v) animations?(v)
}) { [weak self, v = v] _ in }) { [weak self, v = v] _ in
...@@ -466,7 +466,7 @@ extension SpringAnimation { ...@@ -466,7 +466,7 @@ extension SpringAnimation {
options: options, options: options,
animations: { [first = first, v = v] in animations: { [first = first, v = v] in
v.alpha = 0 v.alpha = 0
v.x = first.x + w v.frame.origin.x = first.frame.origin.x + w
animations?(v) animations?(v)
}) { [weak self, v = v] _ in }) { [weak self, v = v] _ in
......
...@@ -76,7 +76,7 @@ open class StatusBarController: TransitionController { ...@@ -76,7 +76,7 @@ open class StatusBarController: TransitionController {
/// An adjustment based on the rules for displaying the statusBar. /// An adjustment based on the rules for displaying the statusBar.
open var statusBarOffsetAdjustment: CGFloat { open var statusBarOffsetAdjustment: CGFloat {
return Application.shouldStatusBarBeHidden || statusBar.isHidden ? 0 : statusBar.height return Application.shouldStatusBarBeHidden || statusBar.isHidden ? 0 : statusBar.bounds.height
} }
/// A boolean that indicates to hide the statusBar on rotation. /// A boolean that indicates to hide the statusBar on rotation.
...@@ -92,20 +92,20 @@ open class StatusBarController: TransitionController { ...@@ -92,20 +92,20 @@ open class StatusBarController: TransitionController {
statusBar.isHidden = Application.shouldStatusBarBeHidden statusBar.isHidden = Application.shouldStatusBarBeHidden
} }
statusBar.width = view.width statusBar.frame.size.width = view.bounds.width
switch displayStyle { switch displayStyle {
case .partial: case .partial:
let h = statusBar.height let h = statusBar.bounds.height
container.y = h container.frame.origin.y = h
container.height = view.height - h container.frame.size.height = view.bounds.height - h
case .full: case .full:
container.frame = view.bounds container.frame = view.bounds
} }
rootViewController.view.frame = container.bounds rootViewController.view.frame = container.bounds
container.zPosition = statusBar.zPosition + (Application.shouldStatusBarBeHidden ? 1 : -1) container.layer.zPosition = statusBar.layer.zPosition + (Application.shouldStatusBarBeHidden ? 1 : -1)
} }
open override func prepare() { open override func prepare() {
...@@ -121,7 +121,7 @@ fileprivate extension StatusBarController { ...@@ -121,7 +121,7 @@ fileprivate extension StatusBarController {
statusBar.backgroundColor = .white statusBar.backgroundColor = .white
} }
statusBar.height = 20 statusBar.frame.size.height = 20
view.addSubview(statusBar) view.addSubview(statusBar)
} }
} }
...@@ -62,7 +62,7 @@ public protocol SwitchDelegate { ...@@ -62,7 +62,7 @@ public protocol SwitchDelegate {
open class Switch: UIControl { open class Switch: UIControl {
/// Will layout the view. /// Will layout the view.
open var willLayout: Bool { open var willLayout: Bool {
return 0 < width && 0 < height && nil != superview return 0 < bounds.width && 0 < bounds.height && nil != superview
} }
/// An internal reference to the switchState public property. /// An internal reference to the switchState public property.
...@@ -309,17 +309,17 @@ open class Switch: UIControl { ...@@ -309,17 +309,17 @@ open class Switch: UIControl {
/// Reloads the view. /// Reloads the view.
open func reload() { open func reload() {
let w: CGFloat = intrinsicContentSize.width let w: CGFloat = intrinsicContentSize.width
let px: CGFloat = (width - w) / 2 let px: CGFloat = (bounds.width - w) / 2
track.frame = CGRect(x: px, y: (height - trackThickness) / 2, width: w, height: trackThickness) track.frame = CGRect(x: px, y: (bounds.height - trackThickness) / 2, width: w, height: trackThickness)
track.cornerRadius = min(w, trackThickness) / 2 track.layer.cornerRadius = min(w, trackThickness) / 2
button.frame = CGRect(x: px, y: (height - buttonDiameter) / 2, width: buttonDiameter, height: buttonDiameter) button.frame = CGRect(x: px, y: (bounds.height - buttonDiameter) / 2, width: buttonDiameter, height: buttonDiameter)
onPosition = width - px - buttonDiameter onPosition = bounds.width - px - buttonDiameter
offPosition = px offPosition = px
if .on == internalSwitchState { if .on == internalSwitchState {
button.x = onPosition button.frame.origin.x = onPosition
} }
} }
...@@ -402,7 +402,7 @@ extension Switch { ...@@ -402,7 +402,7 @@ extension Switch {
s.delegate?.switchDidChangeState(control: s, state: s.internalSwitchState) s.delegate?.switchDidChangeState(control: s, state: s.internalSwitchState)
} }
} else { } else {
button.x = .on == state ? self.onPosition : self.offPosition button.frame.origin.x = .on == state ? self.onPosition : self.offPosition
styleForState(state: state) styleForState(state: state)
guard isTriggeredByUserInteraction else { guard isTriggeredByUserInteraction else {
...@@ -474,7 +474,7 @@ extension Switch { ...@@ -474,7 +474,7 @@ extension Switch {
return return
} }
s.button.x = .on == state ? s.onPosition + s.bounceOffset : s.offPosition - s.bounceOffset s.button.frame.origin.x = .on == state ? s.onPosition + s.bounceOffset : s.offPosition - s.bounceOffset
s.styleForState(state: state) s.styleForState(state: state)
}) { [weak self] _ in }) { [weak self] _ in
UIView.animate(withDuration: 0.15, UIView.animate(withDuration: 0.15,
...@@ -483,7 +483,7 @@ extension Switch { ...@@ -483,7 +483,7 @@ extension Switch {
return return
} }
s.button.x = .on == state ? s.onPosition : s.offPosition s.button.frame.origin.x = .on == state ? s.onPosition : s.offPosition
}) { [weak self] _ in }) { [weak self] _ in
guard let s = self else { guard let s = self else {
return return
...@@ -508,8 +508,8 @@ extension Switch { ...@@ -508,8 +508,8 @@ extension Switch {
return return
} }
let q: CGFloat = sender.x + v.location(in: sender).x - v.previousLocation(in: sender).x let q: CGFloat = sender.frame.origin.x + v.location(in: sender).x - v.previousLocation(in: sender).x
updateSwitchState(state: q > (width - button.width) / 2 ? .on : .off, animated: true, isTriggeredByUserInteraction: true) updateSwitchState(state: q > (bounds.width - button.bounds.width) / 2 ? .on : .off, animated: true, isTriggeredByUserInteraction: true)
} }
/// Handles the TouchUpInside event. /// Handles the TouchUpInside event.
...@@ -529,13 +529,13 @@ extension Switch { ...@@ -529,13 +529,13 @@ extension Switch {
return return
} }
let q: CGFloat = max(min(sender.x + v.location(in: sender).x - v.previousLocation(in: sender).x, onPosition), offPosition) let q: CGFloat = max(min(sender.frame.origin.x + v.location(in: sender).x - v.previousLocation(in: sender).x, onPosition), offPosition)
guard q != sender.x else { guard q != sender.frame.origin.x else {
return return
} }
sender.x = q sender.frame.origin.x = q
} }
} }
......
...@@ -92,7 +92,7 @@ open class TabBar: Bar { ...@@ -92,7 +92,7 @@ open class TabBar: Bar {
let p = q + tabItemsInterimSpace let p = q + tabItemsInterimSpace
for v in tabItems { for v in tabItems {
let x = v.sizeThatFits(CGSize(width: .greatestFiniteMagnitude, height: scrollView.height)).width let x = v.sizeThatFits(CGSize(width: .greatestFiniteMagnitude, height: scrollView.bounds.height)).width
w += x w += x
w += p w += p
} }
...@@ -205,10 +205,10 @@ open class TabBar: Bar { ...@@ -205,10 +205,10 @@ open class TabBar: Bar {
/// The line height. /// The line height.
open var lineHeight: CGFloat { open var lineHeight: CGFloat {
get { get {
return line.height return line.bounds.height
} }
set(value) { set(value) {
line.height = value line.frame.size.height = value
} }
} }
...@@ -240,7 +240,7 @@ open class TabBar: Bar { ...@@ -240,7 +240,7 @@ open class TabBar: Bar {
fileprivate extension TabBar { fileprivate extension TabBar {
// Prepares the line. // Prepares the line.
func prepareLine() { func prepareLine() {
line.zPosition = 10000 line.layer.zPosition = 10000
lineColor = Color.blue.base lineColor = Color.blue.base
lineHeight = 3 lineHeight = 3
scrollView.addSubview(line) scrollView.addSubview(line)
...@@ -277,7 +277,7 @@ fileprivate extension TabBar { ...@@ -277,7 +277,7 @@ fileprivate extension TabBar {
/// Prepares the contentView. /// Prepares the contentView.
func prepareContentView() { func prepareContentView() {
contentView.zPosition = 6000 contentView.layer.zPosition = 6000
} }
/// Prepares the scroll view. /// Prepares the scroll view.
...@@ -293,16 +293,16 @@ fileprivate extension TabBar { ...@@ -293,16 +293,16 @@ fileprivate extension TabBar {
func layoutScrollView() { func layoutScrollView() {
contentView.grid.reload() contentView.grid.reload()
if .scrollable == tabBarStyle || (.auto == tabBarStyle && tabItemsTotalWidth > scrollView.width) { if .scrollable == tabBarStyle || (.auto == tabBarStyle && tabItemsTotalWidth > scrollView.bounds.width) {
var w: CGFloat = 0 var w: CGFloat = 0
let q = 2 * tabItemsInterimSpace let q = 2 * tabItemsInterimSpace
let p = q + tabItemsInterimSpace let p = q + tabItemsInterimSpace
for v in tabItems { for v in tabItems {
let x = v.sizeThatFits(CGSize(width: .greatestFiniteMagnitude, height: scrollView.height)).width let x = v.sizeThatFits(CGSize(width: .greatestFiniteMagnitude, height: scrollView.bounds.height)).width
v.height = scrollView.height v.frame.size.height = scrollView.bounds.height
v.width = x + q v.frame.size.width = x + q
v.x = w v.frame.origin.x = w
w += x w += x
w += p w += p
...@@ -314,7 +314,7 @@ fileprivate extension TabBar { ...@@ -314,7 +314,7 @@ fileprivate extension TabBar {
w -= tabItemsInterimSpace w -= tabItemsInterimSpace
scrollView.contentSize = CGSize(width: w, height: scrollView.height) scrollView.contentSize = CGSize(width: w, height: scrollView.bounds.height)
} else { } else {
scrollView.grid.begin() scrollView.grid.begin()
...@@ -335,12 +335,12 @@ fileprivate extension TabBar { ...@@ -335,12 +335,12 @@ fileprivate extension TabBar {
guard shouldNotAnimateLineView else { guard shouldNotAnimateLineView else {
line.animate(.duration(0), line.animate(.duration(0),
.size(CGSize(width: v.width, height: lineHeight)), .size(width: v.bounds.width, height: lineHeight),
.position(CGPoint(x: v.center.x, y: .bottom == lineAlignment ? height - lineHeight / 2 : lineHeight / 2))) .position(x: v.center.x, y: .bottom == lineAlignment ? bounds.height - lineHeight / 2 : lineHeight / 2))
return return
} }
line.frame = CGRect(x: v.x, y: .bottom == lineAlignment ? scrollView.height - lineHeight : 0, width: v.width, height: lineHeight) line.frame = CGRect(x: v.frame.origin.x, y: .bottom == lineAlignment ? scrollView.bounds.height - lineHeight : 0, width: v.bounds.width, height: lineHeight)
shouldNotAnimateLineView = false shouldNotAnimateLineView = false
} }
...@@ -408,8 +408,8 @@ fileprivate extension TabBar { ...@@ -408,8 +408,8 @@ fileprivate extension TabBar {
selectedTabItem = tabItem selectedTabItem = tabItem
line.animate(.duration(0.25), line.animate(.duration(0.25),
.size(width: tabItem.width, height: lineHeight), .size(width: tabItem.bounds.width, height: lineHeight),
.position(x: tabItem.center.x, y: .bottom == lineAlignment ? height - lineHeight / 2 : lineHeight / 2), .position(x: tabItem.center.x, y: .bottom == lineAlignment ? bounds.height - lineHeight / 2 : lineHeight / 2),
.completion({ [weak self, isTriggeredByUserInteraction = isTriggeredByUserInteraction, tabItem = tabItem, completion = completion] in .completion({ [weak self, isTriggeredByUserInteraction = isTriggeredByUserInteraction, tabItem = tabItem, completion = completion] in
guard let s = self else { guard let s = self else {
return return
...@@ -434,7 +434,7 @@ fileprivate extension TabBar { ...@@ -434,7 +434,7 @@ fileprivate extension TabBar {
} }
if !scrollView.bounds.contains(v.frame) { if !scrollView.bounds.contains(v.frame) {
let contentOffsetX = (v.x < scrollView.bounds.minX) ? v.x : v.frame.maxX - scrollView.bounds.width let contentOffsetX = (v.frame.origin.x < scrollView.bounds.minX) ? v.frame.origin.x : v.frame.maxX - scrollView.bounds.width
let normalizedOffsetX = min(max(contentOffsetX, 0), scrollView.contentSize.width - scrollView.bounds.width) let normalizedOffsetX = min(max(contentOffsetX, 0), scrollView.contentSize.width - scrollView.bounds.width)
scrollView.setContentOffset(CGPoint(x: normalizedOffsetX, y: 0), animated: true) scrollView.setContentOffset(CGPoint(x: normalizedOffsetX, y: 0), animated: true)
} }
......
...@@ -196,6 +196,6 @@ extension TableViewCell { ...@@ -196,6 +196,6 @@ extension TableViewCell {
/// Manages the layout for the visualLayer property. /// Manages the layout for the visualLayer property.
fileprivate func layoutVisualLayer() { fileprivate func layoutVisualLayer() {
visualLayer.frame = bounds visualLayer.frame = bounds
visualLayer.cornerRadius = cornerRadius visualLayer.cornerRadius = layer.cornerRadius
} }
} }
...@@ -306,19 +306,19 @@ fileprivate extension TabsController { ...@@ -306,19 +306,19 @@ fileprivate extension TabsController {
func layoutContainer() { func layoutContainer() {
switch displayStyle { switch displayStyle {
case .partial: case .partial:
let p = tabBar.height let p = tabBar.bounds.height
let y = view.height - p let y = view.bounds.height - p
switch tabBarAlignment { switch tabBarAlignment {
case .top: case .top:
container.y = p container.frame.origin.y = p
container.height = y container.frame.size.height = y
case .bottom: case .bottom:
container.y = 0 container.frame.origin.y = 0
container.height = y container.frame.size.height = y
} }
container.width = view.width container.frame.size.width = view.bounds.width
case .full: case .full:
container.frame = view.bounds container.frame = view.bounds
...@@ -327,9 +327,9 @@ fileprivate extension TabsController { ...@@ -327,9 +327,9 @@ fileprivate extension TabsController {
/// Layout the tabBar. /// Layout the tabBar.
func layoutTabBar() { func layoutTabBar() {
tabBar.x = 0 tabBar.frame.origin.x = 0
tabBar.y = .top == tabBarAlignment ? 0 : view.height - tabBar.height tabBar.frame.origin.y = .top == tabBarAlignment ? 0 : view.bounds.height - tabBar.bounds.height
tabBar.width = view.width tabBar.frame.size.width = view.bounds.width
} }
/// Layout the rootViewController. /// Layout the rootViewController.
......
...@@ -66,7 +66,7 @@ public protocol TextFieldDelegate: UITextFieldDelegate { ...@@ -66,7 +66,7 @@ public protocol TextFieldDelegate: UITextFieldDelegate {
open class TextField: UITextField { open class TextField: UITextField {
/// Default size when using AutoLayout. /// Default size when using AutoLayout.
open override var intrinsicContentSize: CGSize { open override var intrinsicContentSize: CGSize {
return CGSize(width: width, height: 32) return CGSize(width: bounds.width, height: 32)
} }
/// A Boolean that indicates if the placeholder label is animated. /// A Boolean that indicates if the placeholder label is animated.
...@@ -109,7 +109,7 @@ open class TextField: UITextField { ...@@ -109,7 +109,7 @@ open class TextField: UITextField {
return 0 return 0
} }
return leftViewOffset + height return leftViewOffset + bounds.height
} }
/// The leftView offset value. /// The leftView offset value.
...@@ -550,41 +550,41 @@ fileprivate extension TextField { ...@@ -550,41 +550,41 @@ fileprivate extension TextField {
/// Layout the placeholderLabel. /// Layout the placeholderLabel.
func layoutPlaceholderLabel() { func layoutPlaceholderLabel() {
let w = leftViewWidth + textInset let w = leftViewWidth + textInset
let h = 0 == height ? intrinsicContentSize.height : height let h = 0 == bounds.height ? intrinsicContentSize.height : bounds.height
placeholderLabel.transform = CGAffineTransform.identity placeholderLabel.transform = CGAffineTransform.identity
guard isEditing || !isEmpty || !isPlaceholderAnimated else { guard isEditing || !isEmpty || !isPlaceholderAnimated else {
placeholderLabel.frame = CGRect(x: w, y: 0, width: width - leftViewWidth - 2 * textInset, height: h) placeholderLabel.frame = CGRect(x: w, y: 0, width: bounds.width - leftViewWidth - 2 * textInset, height: h)
return return
} }
placeholderLabel.frame = CGRect(x: w, y: 0, width: width - leftViewWidth - 2 * textInset, height: h) placeholderLabel.frame = CGRect(x: w, y: 0, width: bounds.width - leftViewWidth - 2 * textInset, height: h)
placeholderLabel.transform = CGAffineTransform(scaleX: placeholderActiveScale, y: placeholderActiveScale) placeholderLabel.transform = CGAffineTransform(scaleX: placeholderActiveScale, y: placeholderActiveScale)
switch textAlignment { switch textAlignment {
case .left, .natural: case .left, .natural:
placeholderLabel.x = w + placeholderHorizontalOffset placeholderLabel.frame.origin.x = w + placeholderHorizontalOffset
case .right: case .right:
placeholderLabel.x = width - placeholderLabel.width - textInset + placeholderHorizontalOffset placeholderLabel.frame.origin.x = bounds.width - placeholderLabel.bounds.width - textInset + placeholderHorizontalOffset
default:break default:break
} }
placeholderLabel.y = -placeholderLabel.height + placeholderVerticalOffset placeholderLabel.frame.origin.y = -placeholderLabel.bounds.height + placeholderVerticalOffset
} }
/// Layout the detailLabel. /// Layout the detailLabel.
func layoutDetailLabel() { func layoutDetailLabel() {
let c = dividerContentEdgeInsets let c = dividerContentEdgeInsets
detailLabel.height = detailLabel.sizeThatFits(CGSize(width: width, height: .greatestFiniteMagnitude)).height detailLabel.frame.size.height = detailLabel.sizeThatFits(CGSize(width: bounds.width, height: .greatestFiniteMagnitude)).height
detailLabel.x = c.left detailLabel.frame.origin.x = c.left
detailLabel.y = height + detailVerticalOffset detailLabel.frame.origin.y = bounds.height + detailVerticalOffset
detailLabel.width = width - c.left - c.right detailLabel.frame.size.width = bounds.width - c.left - c.right
} }
/// Layout the a button. /// Layout the a button.
func layoutButton(button: UIButton?) { func layoutButton(button: UIButton?) {
button?.frame = CGRect(x: width - height, y: 0, width: height, height: height) button?.frame = CGRect(x: bounds.width - bounds.height, y: 0, width: bounds.height, height: bounds.height)
} }
/// Layout the leftView. /// Layout the leftView.
...@@ -594,7 +594,7 @@ fileprivate extension TextField { ...@@ -594,7 +594,7 @@ fileprivate extension TextField {
} }
let w = leftViewWidth let w = leftViewWidth
v.frame = CGRect(x: 0, y: 0, width: w, height: height) v.frame = CGRect(x: 0, y: 0, width: w, height: bounds.height)
dividerContentEdgeInsets.left = w dividerContentEdgeInsets.left = w
} }
} }
...@@ -705,13 +705,13 @@ extension TextField { ...@@ -705,13 +705,13 @@ extension TextField {
switch s.textAlignment { switch s.textAlignment {
case .left, .natural: case .left, .natural:
s.placeholderLabel.x = s.leftViewWidth + s.textInset + s.placeholderHorizontalOffset s.placeholderLabel.frame.origin.x = s.leftViewWidth + s.textInset + s.placeholderHorizontalOffset
case .right: case .right:
s.placeholderLabel.x = s.width - s.placeholderLabel.width - s.textInset + s.placeholderHorizontalOffset s.placeholderLabel.frame.origin.x = s.bounds.width - s.placeholderLabel.bounds.width - s.textInset + s.placeholderHorizontalOffset
default:break default:break
} }
s.placeholderLabel.y = -s.placeholderLabel.height + s.placeholderVerticalOffset s.placeholderLabel.frame.origin.y = -s.placeholderLabel.bounds.height + s.placeholderVerticalOffset
}) })
} }
...@@ -739,8 +739,8 @@ extension TextField { ...@@ -739,8 +739,8 @@ extension TextField {
} }
s.placeholderLabel.transform = CGAffineTransform.identity s.placeholderLabel.transform = CGAffineTransform.identity
s.placeholderLabel.x = s.leftViewWidth + s.textInset s.placeholderLabel.frame.origin.x = s.leftViewWidth + s.textInset
s.placeholderLabel.y = 0 s.placeholderLabel.frame.origin.y = 0
}) })
} }
} }
...@@ -97,14 +97,14 @@ open class Toolbar: Bar { ...@@ -97,14 +97,14 @@ open class Toolbar: Bar {
titleLabel.sizeToFit() titleLabel.sizeToFit()
detailLabel.sizeToFit() detailLabel.sizeToFit()
let diff: CGFloat = (contentView.height - titleLabel.height - detailLabel.height) / 2 let diff: CGFloat = (contentView.bounds.height - titleLabel.bounds.height - detailLabel.bounds.height) / 2
titleLabel.height += diff titleLabel.frame.size.height += diff
titleLabel.width = contentView.width titleLabel.frame.size.width = contentView.bounds.width
detailLabel.height += diff detailLabel.frame.size.height += diff
detailLabel.width = contentView.width detailLabel.frame.size.width = contentView.bounds.width
detailLabel.y = titleLabel.height detailLabel.frame.origin.y = titleLabel.bounds.height
} }
} else { } else {
detailLabel.removeFromSuperview() detailLabel.removeFromSuperview()
......
...@@ -78,7 +78,7 @@ open class ToolbarController: StatusBarController { ...@@ -78,7 +78,7 @@ open class ToolbarController: StatusBarController {
fileprivate extension ToolbarController { fileprivate extension ToolbarController {
/// Prepares the toolbar. /// Prepares the toolbar.
func prepareToolbar() { func prepareToolbar() {
toolbar.zPosition = 1000 toolbar.layer.zPosition = 1000
toolbar.depthPreset = .depth1 toolbar.depthPreset = .depth1
view.addSubview(toolbar) view.addSubview(toolbar)
} }
...@@ -89,20 +89,20 @@ fileprivate extension ToolbarController { ...@@ -89,20 +89,20 @@ fileprivate extension ToolbarController {
func layoutContainer() { func layoutContainer() {
switch displayStyle { switch displayStyle {
case .partial: case .partial:
let p = toolbar.height let p = toolbar.bounds.height
let q = statusBarOffsetAdjustment let q = statusBarOffsetAdjustment
let h = view.height - p - q let h = view.bounds.height - p - q
switch toolbarAlignment { switch toolbarAlignment {
case .top: case .top:
container.y = q + p container.frame.origin.y = q + p
container.height = h container.frame.size.height = h
case .bottom: case .bottom:
container.y = q container.frame.origin.y = q
container.height = h container.frame.size.height = h
} }
container.width = view.width container.frame.size.width = view.bounds.width
case .full: case .full:
container.frame = view.bounds container.frame = view.bounds
...@@ -111,9 +111,9 @@ fileprivate extension ToolbarController { ...@@ -111,9 +111,9 @@ fileprivate extension ToolbarController {
/// Layout the toolbar. /// Layout the toolbar.
func layoutToolbar() { func layoutToolbar() {
toolbar.x = 0 toolbar.frame.origin.x = 0
toolbar.y = .top == toolbarAlignment ? statusBarOffsetAdjustment : view.height - toolbar.height toolbar.frame.origin.y = .top == toolbarAlignment ? statusBarOffsetAdjustment : view.bounds.height - toolbar.bounds.height
toolbar.width = view.width toolbar.frame.size.width = view.bounds.width
} }
/// Layout the rootViewController. /// Layout the rootViewController.
......
...@@ -32,7 +32,7 @@ import UIKit ...@@ -32,7 +32,7 @@ import UIKit
open class View: UIView { open class View: UIView {
open override var intrinsicContentSize: CGSize { open override var intrinsicContentSize: CGSize {
return CGSize(width: width, height: height) return bounds.size
} }
/** /**
...@@ -196,6 +196,6 @@ extension View { ...@@ -196,6 +196,6 @@ extension View {
/// Manages the layout for the visualLayer property. /// Manages the layout for the visualLayer property.
fileprivate func layoutVisualLayer() { fileprivate func layoutVisualLayer() {
visualLayer.frame = bounds visualLayer.frame = bounds
visualLayer.cornerRadius = cornerRadius visualLayer.cornerRadius = layer.cornerRadius
} }
} }
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