fixed issues for intrinsicSize
Signed-off-by: Matt Bruce <matt.bruce@verizon.com>
This commit is contained in:
parent
3c8176062c
commit
7d892b3190
@ -75,7 +75,13 @@ open class TextLink: ButtonBase {
|
|||||||
|
|
||||||
/// The natural size for the receiving view, considering only properties of the view itself.
|
/// The natural size for the receiving view, considering only properties of the view itself.
|
||||||
open override var intrinsicContentSize: CGSize {
|
open override var intrinsicContentSize: CGSize {
|
||||||
return titleLabel?.intrinsicContentSize ?? super.intrinsicContentSize
|
guard let titleLabel else { return super.intrinsicContentSize }
|
||||||
|
// Calculate the titleLabel's intrinsic content size
|
||||||
|
let labelSize = titleLabel.sizeThatFits(CGSize(width: self.frame.width, height: CGFloat.greatestFiniteMagnitude))
|
||||||
|
// Adjust the size if needed (add any additional padding if your design requires)
|
||||||
|
let adjustedSize = CGSize(width: labelSize.width + contentEdgeInsets.left + contentEdgeInsets.right,
|
||||||
|
height: labelSize.height + contentEdgeInsets.top + contentEdgeInsets.bottom)
|
||||||
|
return adjustedSize
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
|
|||||||
@ -103,9 +103,14 @@ open class TextLinkCaret: ButtonBase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// The natural size for the receiving view, considering only properties of the view itself.
|
/// The natural size for the receiving view, considering only properties of the view itself.
|
||||||
override open var intrinsicContentSize: CGSize {
|
open override var intrinsicContentSize: CGSize {
|
||||||
//get the labels size, if not the button
|
guard let titleLabel else { return super.intrinsicContentSize }
|
||||||
return titleLabel?.intrinsicContentSize ?? super.intrinsicContentSize
|
// Calculate the titleLabel's intrinsic content size
|
||||||
|
let labelSize = titleLabel.sizeThatFits(CGSize(width: self.frame.width, height: CGFloat.greatestFiniteMagnitude))
|
||||||
|
// Adjust the size if needed (add any additional padding if your design requires)
|
||||||
|
let adjustedSize = CGSize(width: labelSize.width + contentEdgeInsets.left + contentEdgeInsets.right,
|
||||||
|
height: labelSize.height + contentEdgeInsets.top + contentEdgeInsets.bottom)
|
||||||
|
return adjustedSize
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user