0
私はUICollectionViewのHeaderViewにUILabelを持っています。ラベルのテキストが表示されますが、いくつかの非常に奇妙な書式の問題があります。すべての線のエッジが非常にギザギザで、非常に悪いです。 UICollectionViewのUILabelでの不規則なテキストの問題
誰にも解決策がありますか?私は以前この問題を見たことがない。カスタムビューのための私のコードは以下の通りです:あなたはあなたのLabel
何回も追加している
func collectionView(collectionView: UICollectionView, viewForSupplementaryElementOfKind kind: String, atIndexPath indexPath: NSIndexPath) -> UICollectionReusableView {
var reusableView = UICollectionReusableView();
if (kind == UICollectionElementKindSectionHeader) {
let header = collectionView.dequeueReusableSupplementaryViewOfKind(UICollectionElementKindSectionHeader, withReuseIdentifier: "SectionHeader", forIndexPath: indexPath)
let label = UILabel()
label.font = UIFont.systemFontOfSize(24.0)
switch indexPath.section {
case 0:
label.text = "UILabel with Weird Text Issues"
default:
label.text = ""
}
label.sizeToFit()
let leftInset = self.cv.contentInset.left
label.frame = CGRectMake(leftInset , header.frame.height-label.frame.height, label.frame.width, label.frame.height)
header.addSubview(label)
reusableView = header
}
return reusableView
}
これは実際のデバイスかシミュレータでですか?時には、物事がシミュレータ上で正しくスケールされないため、ギザギザの線や欠けているピクセルが生じることがあります。 –
これは実際のデバイスからのスクリーンショットです。 – Kenneth