This example demonstrates positioning UI elements using distance constraints to maintain fixed pixel distances from container edges. A logotype is positioned in the top-left corner and a download button in the top-right corner, both with 50px margins.
// Create horizontal constraint
// Logotype 50px from left edge of layer
new UIHorizontalDistanceConstraint(layer, logotype, {
anchorA: 0,
anchorB: 0,
distance: 50,
});
// Create vertical constraint
// Logotype 50px from top edge of layer
new UIVerticalDistanceConstraint(layer, logotype, {
anchorA: 1,
anchorB: 1,
distance: -50,
});