OGeek|极客世界-中国程序员成长平台

标题: iphone - 以编程方式将一些文本添加到 UITextView 中的特定区域? [打印本页]

作者: 菜鸟教程小白    时间: 2022-12-13 13:34
标题: iphone - 以编程方式将一些文本添加到 UITextView 中的特定区域?

我以编程方式创建 UITextView 的实例。我想以编程方式将一些文本添加到 UITextView 的特定区域。这是我创建 UITextView 的代码。

      UITextView *textView =[[UITextView alloc]init];
      textView.frame=CGRectMake(0,0,282,210);
      [textView setReturnKeyType:UIReturnKeyDone];
      [self.view addSubview:textView];

例如,我想在特定区域 CGRectMake(260,190,20,20) 中添加一些文本。 然后将此文本添加到 UITextView。 以编程方式,请任何人指导我,怎么可能做到这一点?



Best Answer-推荐答案


你可以在那里添加一个 UILabel

UITextView *textView = [[UITextView alloc] init];
TextView.frame = CGRectMake(0.0,0.0,282.0,210.0);
[textView setReturnKeyType: UIReturnKeyDone];

UILabel *label = [[UILabel alloc] init];
label.frame = CGRectMake(260.0,190.0,20.0,20.0);
label.text = @"T"; //here you set the text you want...

[textView.view addSubview: label];

[self.view addSubview: textView];

关于iphone - 以编程方式将一些文本添加到 UITextView 中的特定区域?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10464657/






欢迎光临 OGeek|极客世界-中国程序员成长平台 (http://sqlite.in/) Powered by Discuz! X3.4