我正在使用iOS 7中的Text Kit,我在NSTextContainer禁区附近发现了很多奇怪的东西.
我有两种观点:a UITextView和简单的可拖动UIView; 作为UIView移动,我从UIView框架创建了一条bezier路径(调整到UITextView坐标空间内)并更新了UITextViews NSTextContainer的exclusionPaths数组 - 非常简单.
在第一个屏幕截图中,您可以看到Text Kit很好地将文本包装在矩形排除区域周围:

但是,当用户在其中引入换行符时UITextView,TextKit似乎认为禁区的垂直区域要大得多 - 看起来与换行符创建的空格一样高.bezier路径完全相同,所以这似乎是一个Text Kit问题(除非我做错了).

码:
ViewController.h:
@interface ViewController : UIViewController<UITextViewDelegate>
@property (nonatomic, strong) IBOutlet UITextView *textView;
@property (nonatomic, strong) IBOutlet UIView *dragView;
@end
Run Code Online (Sandbox Code Playgroud)
ViewController.m:
-(void)viewDidLoad
{
[super viewDidLoad];
UIPanGestureRecognizer *panRecognizer = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(move:)];
[panRecognizer setMinimumNumberOfTouches:1];
[panRecognizer setMaximumNumberOfTouches:1];
[self.dragView addGestureRecognizer:panRecognizer];
[self updateExclusionZone];
}
-(void)move:(UIPanGestureRecognizer *)pan
{
[self.view bringSubviewToFront:[pan view]];
if …Run Code Online (Sandbox Code Playgroud)