Adding Images to UITextView

后端 未结 5 2211
灰色年华
灰色年华 2020-12-01 04:38

In my app I have a UITextView and a button just below the text view to insert a photo into the UITextView while editing.

My requirement is

5条回答
  •  失恋的感觉
    2020-12-01 05:15

    If you add it only as a subview, some text can be "behind" the image. So add the code which will "tell" the text, that area of the image is inaccessible:

    UIBezierPath *exclusionPath = [UIBezierPath    bezierPathWithRect:CGRectMake(CGRectGetMinX(imageView.frame),    
    CGRectGetMinY(imageView.frame), CGRectGetWidth(imageView.frame), 
    CGRectGetHeight(imageView.frame))];
    
    textView.textContainer.exclusionPaths = @[exclusionPath];
    

提交回复
热议问题