gpt4 book ai didi

ios - 将 UILabel 添加到 UITextView

转载 作者:塔克拉玛干 更新时间:2023-11-02 10:32:00 25 4
gpt4 key购买 nike

我有多个 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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com