improved constraints to center align as requested by design
This commit is contained in:
parent
d9337cadff
commit
f125d55962
@ -15,7 +15,7 @@ open class DoughnutChart: View {
|
|||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
|
|
||||||
public var doughnutLayer = CALayer()
|
public var doughnutLayer = CALayer()
|
||||||
public var titleLabel = Label.createLabelRegularTitleLarge(true)
|
public var titleLabel = Label.createLabelBoldTitleLarge(true)
|
||||||
public var subTitleLabel = Label.createLabelRegularMicro(true)
|
public var subTitleLabel = Label.createLabelRegularMicro(true)
|
||||||
public var labelContainer = View()
|
public var labelContainer = View()
|
||||||
public static let heightConstant: CGFloat = 136
|
public static let heightConstant: CGFloat = 136
|
||||||
@ -49,6 +49,22 @@ open class DoughnutChart: View {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------
|
||||||
|
// MARK: - Initializers
|
||||||
|
//--------------------------------------------------
|
||||||
|
|
||||||
|
public override init(frame: CGRect) {
|
||||||
|
super.init(frame: .zero)
|
||||||
|
}
|
||||||
|
|
||||||
|
public convenience init() {
|
||||||
|
self.init(frame: .zero)
|
||||||
|
}
|
||||||
|
|
||||||
|
public required init?(coder: NSCoder) {
|
||||||
|
fatalError("init(coder:) has not been implemented")
|
||||||
|
}
|
||||||
|
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
// MARK: - Lifecycle
|
// MARK: - Lifecycle
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
|
|||||||
@ -28,34 +28,32 @@ import Foundation
|
|||||||
open override func setupView() {
|
open override func setupView() {
|
||||||
super.setupView()
|
super.setupView()
|
||||||
|
|
||||||
doughnutChart.translatesAutoresizingMaskIntoConstraints = false
|
|
||||||
addSubview(doughnutChart)
|
addSubview(doughnutChart)
|
||||||
colorLablesStack.translatesAutoresizingMaskIntoConstraints = false
|
|
||||||
addSubview(colorLablesStack)
|
addSubview(colorLablesStack)
|
||||||
|
|
||||||
doughnutChart.leadingAnchor.constraint(equalTo: leadingAnchor).isActive = true
|
doughnutChart.leadingAnchor.constraint(equalTo: leadingAnchor).isActive = true
|
||||||
doughnutChart.topAnchor.constraint(equalTo: topAnchor).isActive = true
|
doughnutChart.topAnchor.constraint(greaterThanOrEqualTo: topAnchor).isActive = true
|
||||||
|
|
||||||
bottomAnchor.constraint(greaterThanOrEqualTo: doughnutChart.bottomAnchor).isActive = true
|
bottomAnchor.constraint(greaterThanOrEqualTo: doughnutChart.bottomAnchor).isActive = true
|
||||||
|
|
||||||
let doughnutBottomAnchor = bottomAnchor.constraint(equalTo: doughnutChart.bottomAnchor)
|
let doughnutBottomAnchor = bottomAnchor.constraint(equalTo: doughnutChart.bottomAnchor)
|
||||||
doughnutBottomAnchor.priority = UILayoutPriority(rawValue: 200)
|
doughnutBottomAnchor.priority = UILayoutPriority(rawValue: 200)
|
||||||
doughnutBottomAnchor.isActive = true
|
doughnutBottomAnchor.isActive = true
|
||||||
|
|
||||||
|
bottomAnchor.constraint(greaterThanOrEqualTo: colorLablesStack.bottomAnchor).isActive = true
|
||||||
|
|
||||||
let colorLablesBottomAnchor = bottomAnchor.constraint(equalTo: colorLablesStack.bottomAnchor)
|
let colorLablesBottomAnchor = bottomAnchor.constraint(equalTo: colorLablesStack.bottomAnchor)
|
||||||
colorLablesBottomAnchor.priority = UILayoutPriority(rawValue: 204)
|
colorLablesBottomAnchor.priority = UILayoutPriority(rawValue: 204)
|
||||||
colorLablesBottomAnchor.isActive = true
|
colorLablesBottomAnchor.isActive = true
|
||||||
|
|
||||||
let colorLablesTopAnchor = colorLablesStack.topAnchor.constraint(equalTo: doughnutChart.topAnchor)
|
colorLablesStack.topAnchor.constraint(greaterThanOrEqualTo: topAnchor).isActive = true
|
||||||
|
|
||||||
|
let colorLablesTopAnchor = colorLablesStack.topAnchor.constraint(equalTo: topAnchor)
|
||||||
colorLablesTopAnchor.priority = .defaultLow
|
colorLablesTopAnchor.priority = .defaultLow
|
||||||
colorLablesTopAnchor.isActive = true
|
colorLablesTopAnchor.isActive = true
|
||||||
|
|
||||||
colorLablesStack.topAnchor.constraint(greaterThanOrEqualTo: doughnutChart.topAnchor).isActive = true
|
|
||||||
bottomAnchor.constraint(greaterThanOrEqualTo: colorLablesStack.bottomAnchor).isActive = true
|
|
||||||
trailingAnchor.constraint(equalTo: colorLablesStack.trailingAnchor).isActive = true
|
trailingAnchor.constraint(equalTo: colorLablesStack.trailingAnchor).isActive = true
|
||||||
|
doughnutChart.centerYAnchor.constraint(equalTo: colorLablesStack.centerYAnchor).isActive = true
|
||||||
let centerY = colorLablesStack.centerYAnchor.constraint(equalTo: doughnutChart.centerYAnchor)
|
|
||||||
centerY.priority = UILayoutPriority(rawValue: 500)
|
|
||||||
centerY.isActive = true
|
|
||||||
|
|
||||||
colorLablesStack.leadingAnchor.constraint(equalTo: doughnutChart.trailingAnchor, constant: PaddingThree).isActive = true
|
colorLablesStack.leadingAnchor.constraint(equalTo: doughnutChart.trailingAnchor, constant: PaddingThree).isActive = true
|
||||||
colorLablesStack.backgroundColor = .clear
|
colorLablesStack.backgroundColor = .clear
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user