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 labelContainer = ViewConstrainingView.empty()
|
||||||
var heightConstraint: NSLayoutConstraint?
|
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 {
|
didSet {
|
||||||
if height != oldValue {
|
if height != oldValue {
|
||||||
sizeObject = MFStyler.sizeObjectGeneric(forCurrentDevice: height)!
|
sizeObject = MFStyler.sizeObjectGeneric(forCurrentDevice: height)!
|
||||||
@ -174,14 +174,14 @@ open class DoughnutChart: View, MVMCoreUIViewConstrainingProtocol {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func updateLabelContainer() {
|
func updateLabelContainer() {
|
||||||
|
labelContainer.setNeedsDisplay()
|
||||||
labelContainer.layoutIfNeeded()
|
labelContainer.layoutIfNeeded()
|
||||||
let radius = sizeObject.getValueBasedOnApplicationWidth()/2 - lineWidth()
|
let radius = sizeObject.getValueBasedOnApplicationWidth()/2 - lineWidth()
|
||||||
let labelheight = labelContainer.frame.height/2
|
let labelheight = labelContainer.frame.height/2
|
||||||
let padding = sizeObject.getValueBasedOnApplicationWidth()/2 - sqrt(pow(radius, 2) - pow(labelheight, 2))
|
let padding = sizeObject.getValueBasedOnApplicationWidth()/2 - sqrt(pow(radius, 2) - pow(labelheight, 2))
|
||||||
|
|
||||||
labelContainer.leftPin?.constant = padding
|
labelContainer.leftPin?.constant = padding
|
||||||
labelContainer.topPin?.constant = padding
|
labelContainer.topPin?.constant = max(radius - labelheight, labelheight)
|
||||||
labelContainer.setNeedsDisplay()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user