我使用NSAttributedString
(和NSMutableAttributeString
)通過UIGraphicsBeginPDFContextToFile
寫入PDF。當我輸出帶有下劃線屬性的屬性字符串時,下劃線字母下劃線越過下劃線時下劃線被破壞。解決方法所尋找的解決方法:iOS 6 NSAttributedString Descenders Block Underline
下面是一個示例(截屏)顯示,電流輸出:
這裏是建立該樣本屬性串代碼:
NSAttributedString* ftype =
[[NSMutableAttributedString alloc]
initWithString:@"Dangerous"
attributes:@{
NSParagraphStyleAttributeName:pstyle,
NSFontAttributeName:[UIFont fontWithName:@"TimesNewRomanPS-BoldMT" size:48.0],
NSForegroundColorAttributeName:[UIColor redColor],
NSUnderlineStyleAttributeName:[NSNumber numberWithInt:NSUnderlineStyleSingle]
}
];
我的客戶和我的喜好是下劃線是連續的,理想情況下移到下邊界下方。
手動繪製下劃線比較困難,因爲我們必須在佈局(有時文本不像上面的示例那樣簡單)計算文本的位置。
有沒有人有修復把下劃線要麼a)降低或b)使其連續?
在此先感謝。