Open gongjunnangithub opened 3 years ago
override open var intrinsicContentSize: CGSize { var size = titleLabel?.text?.size(withAttributes: [NSAttributedString.Key.font: textFont]) ?? CGSize.zero size.height = textFont.pointSize + paddingY 2 size.width += paddingX 2 if size.width < size.height { size.width = size.height } if enableRemoveButton { size.width += removeButtonIconSize + paddingX } return size }
size.width += paddingX * 2 tagView的宽度计算建议留一定的余量 size.width +=( paddingX + 1 )* 2 ,某些情况如果paddingX为12.48这种非整数的时候,由于像素不对齐问题,会造成titleLabel尺寸比计算的稍小,造成文字显示不下,显示...这种情况
override open var intrinsicContentSize: CGSize { var size = titleLabel?.text?.size(withAttributes: [NSAttributedString.Key.font: textFont]) ?? CGSize.zero size.height = textFont.pointSize + paddingY 2 size.width += paddingX 2 if size.width < size.height { size.width = size.height } if enableRemoveButton { size.width += removeButtonIconSize + paddingX } return size }