UITextView *text = [[UITextView alloc] initWithFrame:self.frame];
[text setText:@"hello world!"];
text.backgroundColor = [UIColor blueColor];
[self.layer addSublayer:text.layer];
我只能看到蓝色,为什么?
答案 0 :(得分:0)
如果您只看到蓝色,则表示更改text.textColor = [UIColor blackColor];
<强>例如强>
UITextView *text = [[UITextView alloc] initWithFrame:self.frame];
[text setText:@"hello world!"];
text.textColor = [UIColor blackColor];
text.backgroundColor = [UIColor blueColor];
答案 1 :(得分:0)
您不需要混淆视图所拥有的图层的层次结构。只需将视图添加为子视图:
[self addSubview:text];