本文介绍了UITextView 格线随文本调整的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
为了获得带有 UI textview 的格线背景,我从 这里
to get a ruled line background with UI textview i found a code from here
我使用了相同的代码,但根据我的需要,我在代码中添加了一个边距图,该图如下所示
i used the same code, but according to my need i have added a margin figure in the code and the figure looks as follows
现在我希望文本位于边距线旁边,并且在每个段落的第一行中,我想显示从边距到第一个单词的一些空格.如何做到这一点,请指导我
Now i want the text to be places next to the margin line and in the first line of every paragraph i want to show some spaces from the margin to the first word. how to do this please guide me
推荐答案
当填充视图被添加为子视图时,它对我来说是一个很好的边距.
When the padding view was added as subview it worked as a fine margin for me.
UITextView *textView = [[UITextView alloc] initWithFrame:CGRectMake(0, 0, 200, 200)];
textView.backgroundColor = [UIColor redColor];
textView.text = @"SomeText";
UIView *paddingView = [[[UIView alloc]
initWithFrame:CGRectMake(0, 0, 50, 200)] autorelease];
paddingView.backgroundColor = [UIColor whiteColor];
[textView addSubview:paddingView];
[self.view addSubview:textView];
这篇关于UITextView 格线随文本调整的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!