Pus*_*raj 5 overlay uitextview uiimageview ios xcode4.5
我想在文本视图上添加图像,并希望有适当的间距,如屏幕截图所示.

我试图在textview上添加图像,但我在按要求放置文本时遇到问题.请给我一些帮助.
在定义textView和imageView后添加以下代码.
import CoreText.Framework
UIBezierPath *exclusionPath = [UIBezierPath bezierPathWithRect:CGRectMake(0, 0, imageView.frame.size.width, imageView.frame.size.height)];
textView.textContainer.exclusionPaths = @[exclusionPath];
[textView addSubview:imageView];
Run Code Online (Sandbox Code Playgroud)
对核心文本教程有一个清晰的想法,请参阅raywenderlich
在 SWIFT 中:
var exclusionPath:UIBezierPath = UIBezierPath(rect: CGRectMake(0, 0, imageView.frame.size.width, imageView.frame.size.height))
textView.textContainer.exclusionPaths = [exclusionPath]
textView.addSubview(imageView)
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
8550 次 |
| 最近记录: |