UITextView 如何让第一行文字缩进一段距离

解决方案很简单 代码如下

CGFloat labelWidth =85.0;
UITextView  *textView= [[UITextView alloc]initWithFrame:CGRectMake(10, 100,KScreenWidth-20,100)];
textView.textAlignment=NSTextAlignmentLeft;
textView.textColor= [UIColor blackColor];
textView.backgroundColor= [UIColor clearColor];
self.addrssInfoTextView.font= [UIFontsystemFontOfSize:17];
UIBezierPath *bezi = [UIBezierPath bezierPathWithRect:CGRectMake(0,0, labelWidth+10,20)];
textView.textContainer.exclusionPaths=@[bezi];
textView.translatesAutoresizingMaskIntoConstraints=YES;
textView.autoresizingMask=UIViewAutoresizingFlexibleWidth|UIViewAutoresizingFlexibleHeight;
[self.view addSubview:textView];
UILabel* label = [[UILabel alloc]initWithFrame:CGRectMake(0,5, labelWidth,24)];
label.text= @"左边文字";
label.textAlignment=NSTextAlignmentCenter;
label.textColor= [UIColor blackColor];
label.font= [UIFont systemFontOfSize:17];
[textView addSubview:label];

效果如下

UITextView 如何让第一行文字缩进一段距离_第1张图片

你可能感兴趣的:(UITextView 如何让第一行文字缩进一段距离)