Skip to content
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

Assigning a TextAttachment does not apply the image I assigned in the attachment #54

Open
ricardopereira opened this issue Mar 15, 2022 · 0 comments

Comments

@ricardopereira
Copy link

Here is a real example of the issue I'm facing:

An attributed text with an icon set in a UIButton.

let button = UIButton(type: .system)
let attachment = TextAttachment()
attachment.image = MediaActionType.connect.iconImage
let attributedString = "".withAttachment(attachment) + " Connect With \(name)".withTextColor(.brand).withFont(.brandon(style: .medium, size: 16.0))
button.setAttributedTitle(attributedString, for: .normal)

This doesn't show the icon but if works if I use NSMutableAttributedString directly:

let button = UIButton(type: .system)
let attachment = TextAttachment()
attachment.image = MediaActionType.connect.iconImage
let mutableAttributedString = NSMutableAttributedString()
mutableAttributedString.append(NSAttributedString(attachment: attachment))
mutableAttributedString.append(" Connect With \(name)".withTextColor(.brand).withFont(.brandon(style: .medium, size: 16.0)))
button.setAttributedTitle(mutableAttributedString, for: .normal)

I'm using Xcode 13.1, CocoaPods and SwiftyAttributes version is 5.1.1.
Any thoughts?
Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant