update label frame
This commit is contained in:
parent
9329f0ca15
commit
00d78cfded
@ -20,9 +20,9 @@ open class DoughnutChart: View, MVMCoreUIViewConstrainingProtocol {
|
||||
var labelContainer = ViewConstrainingView.empty()
|
||||
var heightConstraint: NSLayoutConstraint?
|
||||
|
||||
private var sizeObject = MFStyler.sizeObjectGeneric(forCurrentDevice: 150)!
|
||||
private var sizeObject = MFStyler.sizeObjectGeneric(forCurrentDevice: 100)!
|
||||
|
||||
var height: CGFloat = 150 {
|
||||
var height: CGFloat = 100 {
|
||||
didSet {
|
||||
if height != oldValue {
|
||||
sizeObject = MFStyler.sizeObjectGeneric(forCurrentDevice: height)!
|
||||
@ -174,14 +174,14 @@ open class DoughnutChart: View, MVMCoreUIViewConstrainingProtocol {
|
||||
}
|
||||
|
||||
func updateLabelContainer() {
|
||||
labelContainer.setNeedsDisplay()
|
||||
labelContainer.layoutIfNeeded()
|
||||
let radius = sizeObject.getValueBasedOnApplicationWidth()/2 - lineWidth()
|
||||
let labelheight = labelContainer.frame.height/2
|
||||
let padding = sizeObject.getValueBasedOnApplicationWidth()/2 - sqrt(pow(radius, 2) - pow(labelheight, 2))
|
||||
|
||||
labelContainer.leftPin?.constant = padding
|
||||
labelContainer.topPin?.constant = padding
|
||||
labelContainer.setNeedsDisplay()
|
||||
labelContainer.topPin?.constant = max(radius - labelheight, labelheight)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user