我正在尝试以编程方式在UIStackView中添加视图。现在我的代码是:
UIView *view1 = [[UIView alloc]init];
view1.backgroundColor = [UIColor blackColor];
[view1 setFrame:CGRectMake(0, 0, 100, 100)];
UIView *view2 = [[UIView alloc]init];
view2.backgroundColor = [UIColor greenColor];
[view2 setFrame:CGRectMake(0, 100, 100, 100)];
[self.stack1 addArrangedSubview:view1];
[self.stack1 addArrangedSubview:view2];
当我部署应用程序时,只有一个视图并且它是黑色的。(view1也获得了view2的参数)
Qyouu
慕森卡