-
-
Notifications
You must be signed in to change notification settings - Fork 212
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Transform original string through style (TextTransform for Style) #93
Comments
Way more difficult than I expected. |
…pport tag attributes and and textTransforms
It will be available inside the next release. Custom Text TransformsSometimes you want to apply custom text transforms to your string; for example you may want to make some text with a given style uppercased with current locale. let allRedAndUppercaseStyle = Style({
$0.font = UIFont.boldSystemFont(ofSize: 16.0)
$0.color = UIColor.red
$0.textTransforms = [
.uppercaseWithLocale(Locale.current)
]
})
let text = "test".set(style: allRedAndUppercaseStyle) // will become red and uppercased (TEST) While let markdownBold = Style({
$0.font = UIFont.boldSystemFont(ofSize: 16.0)
$0.color = UIColor.red
$0.textTransforms = [
.custom({
return "**\($0)**"
})
]
}) All text transforms are applied in the same ordered you set in |
Sometimes it can be useful to have a
Style
capable of transforming the string itself.Our current use case scenario is this one:
Style
&
instead of&
is the most annoying example).UILabel
Another use case scenario is this #91
I believe something like this could work:
Or even something more complex like BonMot is doing here
I'll try to put together a PR.
The text was updated successfully, but these errors were encountered: