5

Is it possible to animate a NSTextAttachment in a UITextView?

I tried modifying its bounds but it doesn't seem to produce any effect.

NSAttributedString *attributedText = self.textView.attributedText;
NSTextAttachment *textAttachment = [attributedText attribute:NSAttachmentAttributeName atIndex:index effectiveRange:nil];
textAttachment.bounds = CGRectMake(0, 0, 1, 1);
[UIView animateWithDuration:1 animations:^{
    textAttachment.bounds = CGRectMake(50, 50, 200, 200);
}];

Is this is not possible with NSTextAttachment, what would you suggest doing to achieve a similar effect?

hpique
  • 119,096
  • 131
  • 338
  • 476
  • It's not clear what effect you're going for. Are you just trying to scale the text? – Matt Long Feb 07 '14 at 23:04
  • No, I'd like to move an image attachment around. – hpique Feb 08 '14 at 01:33
  • Can you elaborate in your question what effect you're going for? Screenshots would also be helpful if you have anything that demonstrates it. – Matt Long Feb 08 '14 at 18:34
  • Have you found a solution to this? – OlgaVogue Oct 27 '15 at 02:48
  • I don't think that NSTextAttachment is animatable. It derives from NSObject so I'd assume UITextView is responsible for laying it out. Would like to know if anyone has devised a solution for this though. – greg Jan 25 '16 at 04:58

0 Answers0