Co-Occurrence tutorial sheet + small bugfixes

This commit is contained in:
relikd
2020-06-26 20:26:30 +02:00
parent 96656438c6
commit 0b6dbfd888
6 changed files with 137 additions and 21 deletions

View File

@@ -13,6 +13,14 @@ extension UIFont {
}
}
extension NSAttributedString {
static func image(_ img: UIImage) -> Self {
let att = NSTextAttachment()
att.image = img
return self.init(attachment: att)
}
}
extension NSMutableAttributedString {
static private var def: UIFont = .preferredFont(forTextStyle: .body)
@@ -31,4 +39,13 @@ extension NSMutableAttributedString {
]))
return self
}
func centered(_ content: NSAttributedString) -> Self {
let before = length
append(content)
let ps = NSMutableParagraphStyle()
ps.alignment = .center
addAttribute(.paragraphStyle, value: ps, range: .init(location: before, length: content.length))
return self
}
}