Created
March 3, 2018 20:24
-
-
Save usagimaru/ad9626def34ecff88fdb2a7098ce8e72 to your computer and use it in GitHub Desktop.
CTParagraphStyle
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var minimumLineHeight: CGFloat = 0 | |
var maximumLineHeight: CGFloat = 0 | |
let paragraphSettings: [CTParagraphStyleSetting] = [ | |
CTParagraphStyleSetting(spec: .minimumLineHeight, valueSize: MemoryLayout<CGFloat>.size, value: &minimumLineHeight), | |
CTParagraphStyleSetting(spec: .maximumLineHeight, valueSize: MemoryLayout<CGFloat>.size, value: &maximumLineHeight) | |
] | |
// sizeof(T) ... MemoryLayout<T>.size | |
let paragraphStyle = CTParagraphStyleCreate(paragraphSettings, paragraphSettings.count) | |
// Attributed String | |
let attributes: [NSAttributedStringKey : Any] = [ | |
NSAttributedStringKey.init((kCTParagraphStyleAttributeName as String)) : paragraphStyle, | |
] | |
let attributedText = NSMutableAttributedString(string: "test", attributes: attributes) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment