I seem to have an issue with changing the transparency with an NSTextAttachment
's image in an NSAttributedString
.
I have a string that I would like to fade in and out, but it seems that the images attached to the string do not fade out along with the text.
I have tried setting both the NSBackgroundColorAttributeName
and NSForegroundColorAttributeName
attribute to the desired alpha, but this does not work.
I am also not seeing an alpha or opacity property with NSTextAttachment
, so the only option I am seeing is attaching a new UIImage
with the corrected alpha, but this approach is going to be a last resort.
I am hoping somebody out there has a method for changing the alpha without me having to do that.
Either Objective-C or Swift code works for me.
As of right now, here is what I am doing:
This method is free for anybody to use. However, I am not happy about this method, because it requires me to keep a copy of the original
UIImage
, and apply the alpha every time to the original, I can't keep reapplying this to theUIImage
that gets returned.