我有多个 UITextView
是我使用 for 循环以编程方式创建的。我正在尝试将 UILabel
添加到每个 UITextView
的左上角。
我该怎么做?
我的 UITextView
代码:
for (int i = 0; i < 10; i++){
UITextView *textView = [[UITextView alloc] initWithFrame:CGRectMake(0, yPos, 375,height)];
[textView setBackgroundColor:[UIColor lightGrayColor]]; //set different property like this
UIColor *borderColor = [UIColor colorWithRed:204.0/255.0 green:204.0/255.0 blue:204.0/255.0 alpha:1.0];
textView.layer.borderColor = borderColor.CGColor;
textView.layer.borderWidth = 1.0;
textView.layer.cornerRadius = 5.0;
textView.textAlignment=NSTextAlignmentRight;
textView.editable=NO;
[CommentScrooll addSubview:textView ];
// CommentScroll Is the name of my viewcontroller
yPos += (height + padding);
}
Objective-c 代码:-
UILabel *cust_Label = [[UILabel alloc] initWithFrame:CGRectMake(Your_X, Your_Y, Your_Width,Your_Height)];
cust_Label.text=@"Your Text";
[textView addSubview: cust_Label];
关于ios - 将 UILabel 添加到 UITextView,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37032070/
欢迎光临 OStack程序员社区-中国程序员成长平台 (https://ostack.cn/) | Powered by Discuz! X3.4 |