ios - Animated UIImage in UITextView with TextKit -
i have uiimage
contains multiple image frames , duration sliced animated gif file. if load image in uiwebview
animate expected, want use uitextview
instead. obvious choice use textkit custom nslayoutmanger
, many custom nsattributedstring
attributes achieve various drawing effects. have single uitextview
i'd give nsattributedstring
contains nstextattachment
s of images need display inline. it's working fine except when load 1 of these animated uiimages
, not animate through frames. thoughts on how accomplish this? i've come theoretical option:
- for each animated image add custom defined attribute
- when layout manager goes draw backgrounds, iterate attribute locate positions of attachment.
- callback text view create
uiimageview
s animated image, add subview, , callstartanimating
i have yet try this, it's hacky. i'm wondering if there's better option.
in summary: want animate uiimage
inside uitextview
via nstextattachment
inside nsattributedstring
without necessity uiimageview
objects. can ignore fact done uiwebview
. uiimage
has properties (images
, duration
) setting animated frames, have configured. if assign uiimageview
animates, if set nstextattachment
, no animation.
i appreciate feedback. thanks!
i think behaviour because uitextview
doesn't display attachments using uiimageview
subviews. when observe view hierarchy , without nstextattachment
s added uitextview
, don't see new views (you can observe view hierarchy using view debugging in xcode, or saying [[[uiapplication sharedapplication] keywindow] recursivedescription]
). presumably, uitextview
draws it's attachments directly.
that said, 1 way can think of include animatable attachment create animated uiimageview
subview of uitextview
, place nslayoutmanager
places nstextattachment
, , scroll whenever uitextview scrolls. can rectangle of nstextattachment
nslayoutmanager
calling boundingrectforglyphrange:intextcontainer:
(possibly in layoutmanager:didcompletelayoutfortextcontainer:atend:
).
Comments
Post a Comment