Ios 文本视图旋转错误
我正在用TextView开发一个应用程序 如果您增加字体大小,旋转文本视图并将其保存到相册中,您将得到像图像一样的白线 有解决办法吗Ios 文本视图旋转错误,ios,rotation,textview,uitextview,Ios,Rotation,Textview,Uitextview,我正在用TextView开发一个应用程序 如果您增加字体大小,旋转文本视图并将其保存到相册中,您将得到像图像一样的白线 有解决办法吗 UIView *trueView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, 900, 1070)]; [trueView setBackgroundColor:[UIColor clearColor]]; trueView.clipsToBounds =YES; UITextView *textView2
UIView *trueView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, 900, 1070)];
[trueView setBackgroundColor:[UIColor clearColor]];
trueView.clipsToBounds =YES;
UITextView *textView2 = [[UITextView alloc]init];
textView2.text = @"abcdefg";
textView2.textContainer.lineFragmentPadding =0;
textView2.textContainerInset = UIEdgeInsetsMake(0, 0, 0, 0);
textView2.autocorrectionType = UITextAutocorrectionTypeNo;
textView2.autocapitalizationType = UITextAutocapitalizationTypeNone;
textView2.userInteractionEnabled = NO;
textView2.textColor = [UIColor blackColor];
textView2.accessibilityLabel =@"0";
textView2.backgroundColor = [UIColor clearColor];
textView2.layer.borderColor = [[UIColor greenColor] CGColor];
textView2.layer.borderWidth = 1.0f;
textView2.textAlignment = NSTextAlignmentLeft;
textView2.font = [UIFont systemFontOfSize:300];
[textView2 setFrame:CGRectMake(6, 415, 895, 369 )];
UIView *textView = [[UIView alloc]initWithFrame:CGRectMake(6, 415, 895, 369)];
[textView addSubview:textView2];
textView2.transform = CGAffineTransformMakeRotation(90);
[trueView addSubview:textView2];
UIGraphicsBeginImageContextWithOptions(CGSizeMake(900, 1070),NO,1);
CGContextRef trueContext = UIGraphicsGetCurrentContext();
CGContextTranslateCTM(trueContext,0, 0);
[trueView.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage *originalImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
UIImageWriteToSavedPhotosAlbum(originalImage, self, nil, nil);
旋转
textView
时,需要扩展其宽度,因为它将剪裁边缘。只需增加宽度并进行相应调整
另一个解决方案是通过设置最小字体大小,自动调整文本大小,使其始终适合任何大小。
查看TextView
最小字体大小上的此线程
另一件需要注意的事情是,如果文本视图只有一行,最好使用
textField
,这将允许您更多地访问诸如截断、最小字体大小和剪裁等内容。请在提问时更具体一点:到目前为止,您在代码示例方面做了哪些尝试?(查看/您期望得到什么?/您会得到什么错误?有关帮助,请查看“”,从iOS11版本中检查此项。