iOSLayoutConstraint

From Xojo Documentation

Class (inherits from Object)

Used to add new auto-layout constraints or modify existing ones.

Properties
Active Offset Scale fa-lock-32.png
FirstAttribute fa-lock-32.png Priority fa-lock-32.png SecondAttribute fa-lock-32.png
FirstItem fa-lock-32.png Relation fa-lock-32.png SecondItem fa-lock-32.png
Shared Properties
StandardGap fa-lock-32.png
Enumerations
AttributeTypes RelationTypes
Constructors

Constructor(firstItem As Object, firstAttribute As AttributeTypes, relation As RelationTypes, secondItem As Object, secondAttribute As AttributeTypes, multiplier As Double, addend As Double, priority As Double = 1000)


Constructor(firstItem As Object, firstAttribute As AttributeTypes, relation As RelationTypes, secondItem As Object, secondAttribute As AttributeTypes, multiplier As Double, gap As StandardGap, priority As Double = 1000)


Example Code

This example adds a new button and constraints to the screen.

Var button As New MobileButton
button.Caption = "OK"
me.AddControl button

// Applying constraints to the screen (Screen1), so they set the position and size of the button when displayed
// (size and position = centered with a margin of 50 points from the parent view edges)

Var RightC As New iOSLayoutConstraint(button,iOSLayoutConstraint.AttributeTypes.Right, iOSLayoutConstraint.RelationTypes.Equal, _
self, iOSLayoutConstraint.AttributeTypes.Right,1.0,-50)

Var LeftC As New iOSLayoutConstraint(button,iOSLayoutConstraint.AttributeTypes.left, iOSLayoutConstraint.RelationTypes.Equal, _
self, iOSLayoutConstraint.AttributeTypes.Left,1.0,50)

Var TopC As New iOSLayoutConstraint(button,iOSLayoutConstraint.AttributeTypes.Top, iOSLayoutConstraint.RelationTypes.Equal, _
self, iOSLayoutConstraint.AttributeTypes.Top,1.0,50)

Var BottomC As New iOSLayoutConstraint(button,iOSLayoutConstraint.AttributeTypes.Bottom, iOSLayoutConstraint.RelationTypes.Equal, _
self, iOSLayoutConstraint.AttributeTypes.bottom,1.0,-50)

me.AddConstraint RightC
me.AddConstraint LeftC
me.AddConstraint TopC
me.AddConstraint BottomC

See Also

MobileScreen class; UserGuide:iOS Auto Layout topic