update left and right padding

This commit is contained in:
Xinlei(Ryan) Pan 2020-01-15 13:28:40 -05:00
parent a318b19410
commit 9329f0ca15

View File

@ -173,10 +173,15 @@ open class DoughnutChart: View, MVMCoreUIViewConstrainingProtocol {
return doughnutChartModel?.spaceRequired ?? true
}
func updateLabelContainer() {
labelContainer.leftPin?.constant = lineWidth()
labelContainer.topPin?.constant = lineWidth()
labelContainer.setNeedsDisplay()
}
func updateLabelContainer() {
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()
}
}