Skip to content

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

@ricardopereira

Description

@ricardopereira

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions