uistackview

UIStackView Distribution Fill Equally

岁酱吖の 提交于 2019-11-26 08:29:56
问题 So, I have a UIStackView that contains four (4) UIView s. If I remove one (1) of those UIView s, the other three (3) will fill the entire space in the UIStackView . MY QUESTION: How can I add a max height on a UIView so that it won\'t fill the entire space of the UIStackView even though the distribution is filled equally? I read something about adding a constraint but I\'m not able to make it work. I\'m using swift by the way. Thank you. 回答1: As a confirmation, this is the current behavior:

Add views in UIStackView programmatically

我只是一个虾纸丫 提交于 2019-11-26 03:48:04
问题 I\'m trying to add views in UIStackView programmatically. 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