Merge branch 'bugfix/TextLinkCaret' into 'release/11_4_0'
added invalidateContentSize after label updates See merge request BPHV_MIPS/vds_ios!181
This commit is contained in:
commit
d360ddffa1
@ -146,7 +146,8 @@ open class ButtonBase: UIButton, ViewProtocol, UserInfoable, Clickable {
|
|||||||
// MARK: - Private Methods
|
// MARK: - Private Methods
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
private func updateLabel() {
|
private func updateLabel() {
|
||||||
|
defer { invalidateIntrinsicContentSize() }
|
||||||
|
|
||||||
//clear the arrays holding actions
|
//clear the arrays holding actions
|
||||||
accessibilityCustomActions = []
|
accessibilityCustomActions = []
|
||||||
if let text, !text.isEmpty {
|
if let text, !text.isEmpty {
|
||||||
|
|||||||
@ -106,12 +106,20 @@ open class TextLinkCaret: ButtonBase {
|
|||||||
open override var intrinsicContentSize: CGSize {
|
open override var intrinsicContentSize: CGSize {
|
||||||
guard let titleLabel else { return super.intrinsicContentSize }
|
guard let titleLabel else { return super.intrinsicContentSize }
|
||||||
// Calculate the titleLabel's intrinsic content size
|
// Calculate the titleLabel's intrinsic content size
|
||||||
let labelSize = titleLabel.sizeThatFits(CGSize(width: self.frame.width, height: CGFloat.greatestFiniteMagnitude))
|
let labelSize = titleLabel.sizeThatFits(CGSize(width: self.frame.width - (contentEdgeInsets.left + contentEdgeInsets.right), height: CGFloat.greatestFiniteMagnitude))
|
||||||
// Adjust the size if needed (add any additional padding if your design requires)
|
// Adjust the size if needed (add any additional padding if your design requires)
|
||||||
let adjustedSize = CGSize(width: labelSize.width + contentEdgeInsets.left + contentEdgeInsets.right,
|
let adjustedSize = CGSize(width: labelSize.width + contentEdgeInsets.left + contentEdgeInsets.right,
|
||||||
height: labelSize.height + contentEdgeInsets.top + contentEdgeInsets.bottom)
|
height: labelSize.height + contentEdgeInsets.top + contentEdgeInsets.bottom)
|
||||||
return adjustedSize
|
return adjustedSize
|
||||||
}
|
}
|
||||||
|
|
||||||
|
open override func layoutSubviews() {
|
||||||
|
super.layoutSubviews()
|
||||||
|
// This ensures the titleLabel is correctly positioned within the button
|
||||||
|
titleLabel?.preferredMaxLayoutWidth = self.frame.width - (contentEdgeInsets.left + contentEdgeInsets.right)
|
||||||
|
super.layoutSubviews() // Calling super again to ensure layout is updated with preferredMaxLayoutWidth
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
extension TextLinkCaret {
|
extension TextLinkCaret {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user