Reputation: 297
There are two subviews in yellow view: red view and green view. Both of them have fixed width and height.
greenView has two more constraint: leading and bottom to the yellow View.
redView has two more constraint: vertical space between bottom to the greenView's top and same centerX with greenView. (Figure 1) (Figure 1)
What I need to do is, always keep redView inside of the yellow View, even if green view's leading constraint to the yellow view is Zero.(Figure 2) What should I do with AutoLayout? Any idea? Thanks.
(Figure 2)
Upvotes: 0
Views: 63
Reputation: 1739
This example makes 3 constraints to the orange view:
1. Leading space >= 0 (priority 1000)
2. Trailing Space >= 0 (priority 1000)
3. CenterX to the green box (priority 999)
Result: (I forgot to remove the margin)
Upvotes: 1