What I have:
This is my hierarchy of views:
What I want to do:
I want to change the alignment of S1 from "Center" to "Top" when I touch the button b1.
What I tried
- (void) changeAlignment {
NSLog(@"P-%li",(long)S1.alignment);
S1.alignment = UIStackViewAlignmentTop;
NSLog(@"P-%li",(long)S1.alignment);
[pView layoutIfNeeded];
}
This sounds obvious but it does not work!!. The funny thing is that it works at some time but suddenly it stops working. Now when I tap b1, the alignment of S1 changes but visually it does not change at all.
I've trying with [self.view setNeedsLayout] [self.view layoutIfNeeded] and even [S1 layoutIfNeeded] and none of this have work.
What I'm doing wrong??..How it is even possible that it actually works and suddenly stop working!!??
Can anybody please help me??...this is drive me crazy.
I think the answer of this is the same as in How to programmatically animate the alignment property of an UIStackView in ios 9.
The explanation for this behaviour is the following: