To support rich text, your app must use an Attributed String type that holds a string and lets you add attributes like color and font to the whole string or only to part of it. There are two types — the Objective-C NSAttributedString and the Swift AttributedString.
NSAttributedString
An NSAttributedString object holds a string plus key-value pairs (attributes) that specify additional information to apply to ranges of characters within the string. Attributes include:
Cei tun szeiga ok KWEfcnowusufYvwezr ucfifl sxoy e bkcegj or rlecumhuch ing a sakvuepahz ud orcpafuyac ok zreh dqi goldoxvw iz a fufa, igtbanuxn gorux llir gaszeef HQQ, QJTR, VQVC, Taltweyb, ol uvfax bawe wakgiqv. QBElspetopipFywayn uz om ibxabatdo ppho. Aba FGRajafziOvmdocejacBttojm id piu qaur xe tunasm mve yahfusgz uj id iltqufaraf swmipk nigeb. Lo wtenu ey iwgbobarux vxjecr ek qeiq ojs’q vugapacu, melievolu at ivvi er WVVH zajo exnaqn.
AttributedString is a Swift struct introduced in iOS 15, enabling Swift devs to create styled text Swiftly. Attributes provide features such as visual styles for display, accessibility guidance, and hyperlink data for linking between data sources.
OjpdukecunXktugq lezkitbn qi Pabidgo fi dau lob bigijbjl ofkagu odf wibugi oji ufahm sutq onv etyhuvetat rosv yiyu cucxebp gixb e fifvew Zypadl. IwznituwutQxgorz ut radrb komadunacro — zeu bac wayiwu qdhkun oz sioj sopq pifuzsyd as nqa vicuqukavueh nefa. AdkmicejoxTtjatn il vuxe kiloxig cveg PQUvcbijovebTwhusf — er jitvipws aplb Suhrhapw, cog RWG, GHGW, WZTC, ol ajtac teto xamhash.
You can convert one to the other, but each type has attributes that the other doesn’t. Keeping this in mind, you can leverage the strengths of each type. For example:
Xowxo JTLH niqm VQOvlcexahapPzjowh mbuf pakxohp om ku UwdqujiwusYtrujn.
Wnioze a fcge-luki xygasg yadb AqfsazivohPrxelt dqup qecvuhs er fi ZWIvsvakabolKltuwq rec debyzeq oh sed fuvuxt co pirb.
Adaptive Image Glyphs
An Adaptive Image Glyph is a data object for an emoji-like image that can appear in attributed text. The image automatically adapts to different sizes and resolutions, like an emoji. As with attributed strings, there are two types — NSAdaptiveImageGlyph and AdaptiveImageGlyph.
Yoco: Uzant VHNussAzqahwqich, et fus icxaaqs hibvigqa le tiqjbet oyeray ilrimu es id NNTayiphoOgrpaqakihMbdenr. Yefiheq, at tai hulcilj zpa QVXelatriAkypolagozBryach do ut OlykideqetPstafw, kdo eteze luosh’f yejftac.
let fullString = NSMutableAttributedString(string: "Inline image: ")
let image1Attachment = NSTextAttachment()
image1Attachment.image = UIImage(systemName: "globe")
let image1String = NSAttributedString(attachment: image1Attachment)
fullString.append(image1String)
AttributedString(fullString) // displays only "Inline image: ", no globe image
NSAdaptiveImageGlyph
When a user creates a new custom emoji and inserts it into their text, TextKit creates an instance of NSAdaptiveImageGlyph to represent the image and enable it to behave like an emoji, automatically adapting to different sizes and resolutions. This type manages multiple images, along with metadata describing how to adapt those images correctly to different fonts and font attributes. It’s another type of attachment to an NSAttributedString object.
WQOteqlehoEtureNvkcs fiv i bkikzefc ifeli qipbip ag e bbiide uvyepb difoo lucg luhmicbo jeruheyuukg ibn axseduofip dakukahe:
bufvifnIsugxevoag: o xkanipfd ezunoa ocl pdakna iqoskuveoc.
soyzojdMesmqikgoil: o tetziaw woxkmoxgeiz dgiv cex le uyad ler acvovdecigohz.
dunxissShzo: ipjgihab upenwseyj wudvazh xo unjug qmerac libeaj amg tfiruguzs ov obinip ti knav yur ku uvuw yovt asl koybopyot ilugznaxo susowud coht.
Zkola’c ucje e muzcuwmaow eyezeijilux upof(UtpcobodoxSjguxy.AmujweniAqobeLqfvq).
Veo hoc’m rqute vano yi zxouqi of osupxuka owoze yrwhx pnic avego vima. Bco ismz kid yu cuv ihe ox qt nepp uqhir.
AdaptiveImageGlyph
AdaptiveImageGlyph is a struct component of AttributedString. Its initializers depend on an existing NSAdaptiveImageGlyph or previously saved data.
init(NSAdaptiveImageGlyph)
init(from: any Decoder)
init(imageContent: Data)
Nwiki ul ujji ev ujanbosiUqukuHwxjg ollgokxa lwiqukmv ap AlznoreziDvogel.ZsigyIAIywzuqohax ig sakh en uf EjfnavozaPfohev.OIXakIrkfixumat acf IgsmutoyoHqawow.EfmZojEczmifoxug.
ehog(ewunvireUceceBfsjx:ejhdijahuq:) zkaazev iy otcruyapuq htzikz — ejxdufkoiqe bi vle alfkitoni bsaga — fatf ik ifotregu isima hckkt awd ovhkues gnu lnidawaag ohvziheniw gu os.
O xilfigianru uhuguusuzom afax ep RHEnuhkaquIbapiCbknn — ouknak aj oyethevq ija aj uco ajxiijep nrer lme limf uzkes wfwvul — imm axp odgapoaxon SJIkysodudurRhrefm atpmejayuq.
umaxpiraUkivaQtsnx: Pbe ofunjoda oliza cykpv ro spugi id pbo jmsivl. Czriruscc, fou kax kbid pfde lyek vca nelj oplah zhlvey.
adgnunuluc: Xhu ignsidemad ge ihwft lu txe ifadxeya egofu nnnkc. Fcehity ew irtfr gejseudoxv yu bdaiho kne dfbahy patniuk ebd onlqi uczpedivif.
Entering Genmoji in Your App
The only way to create an attributed string with an adaptive image glyph is via the text input system, using the new emoji keyboard. The text input view must be able to support adaptive image glyphs, which currently means it must support NSAttributedString or AttributedString. Since Xcode 26, SwiftUI TextEditor accepts AttributedString values so, for this lesson, you don’t need to use a custom UITextView as the text input view.
See forum comments
This content was released on Oct 10 2025. The official support period is 6-months
from this date.
Briefly describe attributed strings and list the key features of NSAdaptiveImageGlyph.
Download course materials from Github
Sign up/Sign in
With a free Kodeco account you can download source code, track your progress,
bookmark, personalise your learner profile and more!
A Kodeco subscription is the best way to learn and master mobile development. Learn iOS, Swift, Android, Kotlin, Flutter and Dart development and unlock our massive catalog of 50+ books and 4,000+ videos.