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 return doughnutChartModel?.spaceRequired ?? true
} }
func updateLabelContainer() { func updateLabelContainer() {
labelContainer.leftPin?.constant = lineWidth() labelContainer.layoutIfNeeded()
labelContainer.topPin?.constant = lineWidth() let radius = sizeObject.getValueBasedOnApplicationWidth()/2 - lineWidth()
labelContainer.setNeedsDisplay() 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()
}
} }