Fork me on GitHub

在界面中显示文本内容

iOS有单行和多行显示文本的控件对象:

  • UITextField:简单的单行
  • UITextView:可滚屏的多行

在这里使用的是多行文本,即UITextView。

image

 

代码很简单,需要声明该视图的位置,字体颜色,背景色,是否可编辑以及是否可滚动。

textview=[[UITextView alloc] initWithFrame:CGRectMake(550, 140, 400, 300)]; 
textview.backgroundColor = [UIColor colorWithWhite:0 alpha:0]; 
textview.textColor = [UIColor blackColor]; 
textview.font = [UIFont fontWithName:@"Arial" size:24]; 
textview.editable = YES; 
textview.scrollEnabled = YES;

posted on 2012-02-10 11:51  pengyingh  阅读(235)  评论(0编辑  收藏  举报

导航