簡體   English   中英

iOS 子視圖中的像素化文本

[英]pixelated text inside subviews in iOS

像素化文本

當我嘗試使用 iPhone 11 Pro Max 模擬器時,文本是像素化的,iPhone 11 Pro 模擬器問題較少,iPhone SE 模擬器沒有問題。

信息披露:

  • 我使用
chartLegendLabel.sizeToFit()
let textWidth = chartLegendLabel.frame.width
let textHeight = chartLegendLabel.frame.height
chartLegendLabel.edgesToSuperview(insets: TinyEdgeInsets(top: barContainerContainer.frame.height - textHeight - 16, left: barContainerContainer.frame.width - textWidth - 16, bottom: 4, right: 4) )
chartLegendLabel.layer.borderColor = UIColor.darkGray.cgColor
chartLegendLabel.layer.borderWidth = 1.0

我剛剛使用 Interface Builder 安排的其他文本。 自動調整大小已打開。

非常感謝您的幫助

在我的陰影函數中添加了這一行layer.shouldRasterize = false (它為文本的超級視圖添加了陰影),一切都解決了。

static func shadow(in layer:CALayer){
        layer.shadowColor = UIColor.lightGray.cgColor
        layer.shadowOffset = CGSize(width:1,height:5)
        layer.shadowOpacity = 0.8
        layer.shadowRadius = 10
        layer.masksToBounds = false
        layer.shouldRasterize = false
}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM