1

下面的文字我想写在 UITextView 那么我怎么能写在 UITextView

Provides freeze protection to -45°F to ensure a clean, clear windshield

    >Concentrated formula
    >Provides freeze protection to -45°F
    >Removes road film and bug splatter
    >Use year-round
    >Choose the freeze protection you need
    >Contains a special bittering agent
    >Harmless to car finishes when used as directed

我想要 UITextView 中的类似结构。是否可以?

4

4 回答 4

2

您可以设置任何您想要使用的文本:

yourTextView.text = @"YOUR TEXT HERE";

因此,如果您想拥有与我们展示的相同结构:

yourTextView.text = @"Provides freeze protection to -45°F to ensure a clean, clear windshield\n\n >Concentrated formula\n >Provides freeze protection to -45°F\n >Removes road film and bug splatter\n >Use year-round\n >Choose the freeze protection you need\n >Contains a special bittering agent\n >Harmless to car finishes when used as directed";
于 2012-10-18T08:36:17.113 回答
2

只需按照您的要求格式化字符串:

yourTextView.text = [NSString stringWithFormat:@" Provides freeze protection to -45°F to ensure a clean, clear windshield\n    >Concentrated formula\n    >Provides freeze protection to -45°F\n    >Removes road film and bug splatter\n    >Use year-round\n    >Choose the freeze protection you need\n    >Contains a special bittering agent\n    >Harmless to car finishes when used as directed"];
于 2012-10-18T08:36:35.320 回答
2

您可以以编程方式执行此操作。

textView.text = @"Type your text here"...

您可以将 \n 用于新行,将 \t 用于标签栏空间。

试试这个

于 2012-10-18T10:08:07.360 回答
0

利用文本视图文本中'\n'的新行开始和'\t' (Escape sequences)选项卡空间。

于 2012-10-18T08:49:41.310 回答