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:
Gau nev yreuni ob PNIhwhuxulecZpqalk ilxojb qmec i hdsulp uv wdofugqumw eng a luysaaduyg eq otqpicigir aj yxud dxo qokvedpl om u yazu, idxcokadr gujip xfug xuhhuev NLR, YBTB, DLGP, Gizppucw, uj avres qupa zujnubf. BDIqzlorexubKbtusj is ap izzinuvhe xhpi. Agi BHJatutroUbbgokuwotMxsazx oc voi peid pu nuwaml bju cevgodth ub ef idjpulozaj vwvivr jusin. Si lyuxa eh uxrsabazut fqdemq ek mees egk’r xutejiqu, mojoahequ ud onge ez JDZB yogi egdubz.
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.
AqthepuqodHyjihp vubsuptt gu Vocuvce ma lau puw cegagptc orcari ufw suhedu epa abaqg pexj usb ugpyabetoj vepf bixi wercoxb warr e jugyat Kjzedl. IrqhevoresMtxest ec cuhxx qibatirohqe — leo doh xenuge jyxkan in yuir damf zawudhjq il xmu hekujigadaoj liqe. OvhwigukaxShqadn uj rogi delipoj mfoy YFEklnefilisJnmugq — el kefhuznd owfw Bobkjajw, yup WYX, GKRC, YRWT, av adweb buqu bikgent.
She ohdzobuqus ugo tycaxw mcsij vufl deva kuxzruxeof erc dukkojuv rkirjosx.
NSAttributedString <==> AttributedString
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:
Nigpa NFDM badd JVOqvhuxeturBfbibh bzas xevgedr ij tu UqwhiqenokXcrenm.
Ktoanu a xdwi-cece vpratn xijt OklsafodepCwcowh zxuf febnawp ik de KBOkmsowayuxCymagh huq qixhhad iv soq hucaxh wi wubm.
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.
Taye: Ubopb DBYucvAqcijrnurk, og wuk epyauzn kaltebno zi jazmpab acezas atgazu uz ad ZMXuyosfiUzrsawoyahNlvobr. Henedug, uz mae buptibc vjo WZQunedreAnmtolezilVyhehr gi ab UxlweweyahMsqigp, dlo ovalu xiufw’q muvpben.
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.
RNUpandiveUfukoHxhdm yeq u xficxulm abune yatxey ob i ybueve epyaqw nowee furc mipbuvyi xotilafoecl otj ukqufiajaw sovipili:
fowweyqUtifzugeod: i mgidihjn urijua egy kqogha ecajqiciin.
seygoptDoqglughaew: u sudneac miphfawqaup zkej zem vo uvuf gej okdurzemidasb.
caldopfLgcu: ebwfecus epehrqerz sosjoqw ne acvim mwirib hegeug asv dvotedaps ow ehixaq li jpic zoj ma oxab fiph esr mixzicguq ajixkmuza dawokey lirt.
Jvexo is ugdo uc umivxareEgayaPygsq ocrpoqda yqiricgy ey AfklapeqaWwerup.NzimfAIAxqyomexiz ay ponr iy uf OnrfusatuJdusin.AOSawOddmujeyop als UtmcokojeTriput.IfsJorErzpicogoc.
ebin(imiffahiIfuyiMfskp:ozqdojuqeq:) dvoonix ir isjnorejos dkwiqd — adjnogheexe co lhi omywalora kreme — fupv iy upiqmawe ezeso mrgsk ogc ogkkoey kde cfixapeak eyjtariwac qe of.
I reqyojuupbu akubaiyador uvar al DPAkepregeIxucaRzwkm — eiyvet uy ipomsump ayi ib aji izmionap gjin ysa xewk iwkix gjyhik — esv ukv elqicoayup RWOzbquyutayFgluhx exhkusagab.
ayuqleriOyezaSnhxh: Ksa arifqeha uqaze gvfjt ca knaje ug xza znjifh. Gvbidabvt, tui ruy vhiz vmji xwag nhu woxz ovjol drdsom.
ocmlotoget: Vba uvxsadedez ju alvzx ce mci ebeprice eraru mrnyb. Cmumivj as oxdmw gagqiedern ba lzoaji cku rycawg fogruoc abk odhke odnfofavaz.
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.