I'd like to slightly modify the y position of a character in an NSAttributedString
. I know I can subscript (or superscript) using the attribute dictionary:
@{(id)kCTSuperscriptAttributeName: @(-1)}
Unfortunately the shift caused by this is too large in my case. I'm looking for an option to adjust the baseline in 1-point steps.
The attributed string will be displayed in a UIButton
using -setAttributedTitle:forState:
.
As of iOS 7 the NSBaselineOffsetAttributeName
attribute has been added.
Yes you can... but only if you draw the text yourself like I am doing it in my DTCoreText open source project.
See line 924ff in DTCoreTextLayoutFrame.m here: https://github.com/Cocoanetics/DTCoreText/blob/master/Core/Source/DTCoreTextLayoutFrame.m
Unfortunately that's the ONLY way I know how to. UIKit does not give you this option.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With