我有一個CATextlayer的問題。我爲CATextlayer設置了包裝== YES,並自動爲此設置多行。但行間距非常小,看起來很糟糕。 有沒有辦法爲CATextlayer設置行間距?謝謝。CATextlayer設置行距?
3
A
回答
0
您可以參考以下教程:
2
我覺得CATextLayer
僅用於輕量級的使用。您可以將其string
屬性設置爲NSAttributedString
以更改字體和大小等屬性,但會忽略其他屬性,包括行高和間距。
爲了更好地控制圖層中文本的呈現方式,您可以使用常規的CALayer
和NSAttributedString
的繪圖方法;例如:
- (void)drawLayer:(CALayer *)layer inContext:(CGContextRef)ctx {
[NSGraphicsContext saveGraphicsState];
[NSGraphicsContext setCurrentContext:[NSGraphicsContext graphicsContextWithGraphicsPort:ctx flipped:YES]];
[self.someAttributedString drawInRect:layer.bounds];
[NSGraphicsContext restoreGraphicsState];
}
相關問題
- 1. 將UITextLayer文本設置爲CATextLayer?
- 2. 如何爲CATextLayer()設置系統字體?
- 3. 多行CATextLayer
- 4. Imagemagick設置行間距?
- 5. 設置UILabel行間距
- 6. CTParagraphStyleSetting + CoreText:設置行距
- 7. 如何設置行距Graphics.DrawString
- 8. UILabel默認字距不同於CATextLayer
- 9. 多行CATextLayer截斷
- 10. CATextlayer中的行數?
- 11. Emacs設置行間距(行尾)註釋
- 12. 在錶行之間設置邊距
- 13. 設置邊距的行動佈局
- 14. 用VBA設置頁腳的行間距
- 15. CATextLayer fontColor?
- 16. CATextLayer和
- 17. Typo3記錄間距/邊距設置
- 18. 如何爲CATextLayer設置動畫的字符串屬性
- 19. 設置打印頁邊距
- 20. 在ImageView上設置邊距
- 21. 設置傳呼距離
- 22. 邊距設置爲TextView的
- 23. AndroidPlot設置網格間距
- 24. AutoLayout和CATextLayer iOS7
- 25. CATextLayer旋轉?
- 26. CATextLayer包裹sizeToFit?
- 27. CATextLayer的解析
- 28. CATextLayer忽略NSMutableParagraphStyle
- 29. CATextLayer + NSAttributtedString + CTParagraphStyleRef
- 30. Mix CATextLayer和CAScrollLayer
這根本不回答問題。問題是關於改變'CATextLayer'的行間距,而不是關於計算特定寬度的高度...... – NSAddict