大佬教程收集整理的这篇文章主要介绍了objective-c – iOS 7中的换行符UITextView打破Text Kit禁用区域换行,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
@L_874_0@两个视图:一个UITextView和一个简单的可拖动的UIView;当UIView移动时,我从UIView的框架创建了一条bezier路径(调整到UITextView的坐标空间内),我更新了UITextView的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
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 ([pan state] == UIGestureRecognizerStateBegan) { NSLog(@"pan began"); } self.dragView.center = [pan LOCATIOnInView:self.view]; [self updateExclusionZone]; if ([pan state] == UIGestureRecognizerStateEnded) { NSLog(@"pan ended"); } } -(void)updateExclusionZone { CGRect dragViewFrame = self.dragView.frame; CGRect exclusionRect = [self.view convertRect:dragViewFrame toView:self.textView]; UIBezierPath *exclusion = [UIBezierPath bezierPathWithRect:exclusionRect]; self.textView.textContainer.exclusionPaths = @[exclusion]; }
有什么想法吗?
以上是大佬教程为你收集整理的objective-c – iOS 7中的换行符UITextView打破Text Kit禁用区域换行全部内容,希望文章能够帮你解决objective-c – iOS 7中的换行符UITextView打破Text Kit禁用区域换行所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。