問題:
I'm trying to add views in UIStackView programmatically.我正在嘗試以編程方式在 UIStackView 中添加視圖。 For now My code is:現在我的代碼是:
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];
When i deploy the app, there is only 1 view and it is with black colour.(view1 get the parameters for view2 too)當我部署應用程序時,只有 1 個視圖,它是黑色的。(視圖 1 也獲取視圖 2 的參數)
解決方案:
參考一: https://en.stackoom.com/question/24vlu參考二: https://stackoom.com/question/24vlu