File tree Expand file tree Collapse file tree 1 file changed +10
-1
lines changed
Sources/SwiftRichString/Extensions Expand file tree Collapse file tree 1 file changed +10
-1
lines changed Original file line number Diff line number Diff line change @@ -95,7 +95,16 @@ public extension AttributedString {
9595 #else
9696 var attachment : NSTextAttachment !
9797 if #available( iOS 13 . 0 , * ) {
98- attachment = NSTextAttachment ( image: image)
98+ // Due to a bug (?) in UIKit we should use two methods to allocate the text attachment
99+ // in order to render the image as template or original. If we use the
100+ // NSTextAttachment(image: image) with a .alwaysOriginal rendering mode it will be
101+ // ignored.
102+ if image. renderingMode == . alwaysTemplate {
103+ attachment = NSTextAttachment ( image: image)
104+ } else {
105+ attachment = NSTextAttachment ( )
106+ attachment. image = image. withRenderingMode ( . alwaysOriginal)
107+ }
99108 } else {
100109 attachment = NSTextAttachment ( data: image. pngData ( ) !, ofType: " png " )
101110 }
You can’t perform that action at this time.
0 commit comments