Commit 15a0e382 by Daniel Dahan

development: added ContentViewAlignment enum to ControlView

parent fdc45a95
......@@ -30,9 +30,15 @@
import UIKit
@objc(ContentViewAlignment)
public enum ContentViewAlignment: Int {
case any
case center
}
open class ControlView: View {
/// Should center the contentView.
open var isCenteredContentView = false {
open var contentViewAlignment = ContentViewAlignment.any {
didSet {
layoutSubviews()
}
......@@ -201,7 +207,7 @@ open class ControlView: View {
grid.views.append(v)
}
if isCenteredContentView {
if .center == contentViewAlignment {
if lc < rc {
contentView.grid.columns = columns - 2 * rc
contentView.grid.offset.columns = rc - lc
......
......@@ -94,7 +94,7 @@ open class Toolbar: BarView {
}
open override func observeValue(forKeyPath keyPath: String?, of object: Any?, change: [NSKeyValueChangeKey : Any]?, context: UnsafeMutableRawPointer?) {
isCenteredContentView = .center == titleLabel.textAlignment || .center == detailLabel.textAlignment
contentViewAlignment = .center == titleLabel.textAlignment || .center == detailLabel.textAlignment ? .center : .any
}
open override func layoutSubviews() {
......
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