0
    
 NSAttributext iOS
Mình đang có 1 label dùng nsattributext để hiển thị với font chữ HiraginoSans-W3 or HiraginoSans_W6 (tiếng Nhật). nhưng khi sử dụng thì các chữ cái Latin như "g", "p".. bị mất 1 phần nhỏ dứoi bottom. Không biết mọi người đã gặp trường hợp như trên chưa ạ ?
            Thêm một bình luận
         
2 CÂU TRẢ LỜI
        +2
    
 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
        }
    }
}
        +1
    
 Theo mình nghĩ vấn đề ở đây là do font chữ. 
 Font tiếng Nhật nó viết giữa 2 dòng kẻ, nên chữ latin viết sát dòng kẻ có chân sẽ ko hiện được!
 
  
  
  
 