Można dodać widok obrazu jako podrzędny o UITextView
.
Załóż ImageView z obrazka:
UIImageView *imageView = [[UIImageView alloc] initWithImage:yourImage];
[imageView setFrame:yourFrame];
[yourTextView addSubview:imageView];
EDIT:
Dla uniknięcia nakładającą wykorzystania (dzięki @chris):
CGRect aRect = CGRectMake(156, 8, 16, 16);
[imageView setFrame:aRect];
UIBezierPath *exclusionPath = [UIBezierPath bezierPathWithRect:CGRectMake(CGRectGetMinX(imageView.frame), CGRectGetMinY(imageView.frame), CGRectGetWidth(yourTextView.frame), CGRectGetHeight(imageView.frame))];
yourTextView.textContainer.exclusionPaths = @[exclusionPath];
[yourTextView addSubview:imageView];
Ale w jaki sposób zapobiec ImageView z obejmujące tekst w tekście tekstowym? Jak uzyskać tekst płynący wokół widoku obrazu? –
CGRect aRect = CGRectMake (156, 8, 16, 16); [attachmentView setFrame: aRect]; UIBezierPath * exclusionPath = [UIBezierPath bezierPathWithRect: CGRectMake (CGRectGetMinX (attachmentView.frame) CGRectGetMinY (attachmentView.frame) CGRectGetWidth (internalTextView.frame) CGRectGetHeight (attachmentView.frame))]; internalTextView.textContainer.exclusionPaths = @ [exclusionPath]; [internalTextView addSubview: attachmentView]; –