NSAttributext iOS
 
 
                    Thanh Nguyen
                 
                    Đã trả lời thg 3 5, 2019 12:15 CH
                
Các font chữ tiếng Nhật thường bị như vậy. Cách khắc phục: Dùng custom class cho label, button... kiểu như này để tăng intrinsicContentSize height lên.
class CustomLabel: UILabel {
    open override var intrinsicContentSize: CGSize {
        var size = super.intrinsicContentSize
        size.height += (0.275 * font.pointSize)
        return size
    }
    override func sizeToFit() {
        super.sizeToFit()
        frame.size = intrinsicContentSize
    }
}
class CustomButton: UIButton {
    override func layoutSubviews() {
        super.layoutSubviews()
        titleLabel?.sizeToFit()
        if let titleLabel = self.titleLabel {
            var frame = titleLabel.frame
            let adjustHeight = 0.275 * titleLabel.font.pointSize
            frame.size.height += adjustHeight
            frame.origin.y -= (adjustHeight / 2)
            titleLabel.frame = frame
        }
    }
}
 
        +2
     
Tổ chức
Chưa có tổ chức nào.
 
 