Commit 68e44743 by Daniel Dahan

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

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