You’re welcome! Glad I could help. Here is another to use with controls that have a more variable size (i.e. rectangles, ovals, etc)
[code]Sub AddControlWithBounds(extends mView as iOSView, ctrl as iOSControl, bounds as xojo.Core.Rect)
Dim left As New iOSLayoutConstraint(ctrl, _
iOSLayoutConstraint.AttributeTypes.Leading, _
iOSLayoutConstraint.RelationTypes.Equal, _
mView, _
iOSLayoutConstraint.AttributeTypes.Leading, _
1, _
bounds.left)
mView.AddConstraint(left)
Dim top As New iOSLayoutConstraint(ctrl, _
iOSLayoutConstraint.AttributeTypes.Top, _
iOSLayoutConstraint.RelationTypes.Equal, _
mView, _
iOSLayoutConstraint.AttributeTypes.Top, _
1, _
bounds.top)
mView.AddConstraint(top)
Dim right As New iOSLayoutConstraint(ctrl, _
iOSLayoutConstraint.AttributeTypes.Right, _
iOSLayoutConstraint.RelationTypes.Equal, _
mView, _
iOSLayoutConstraint.AttributeTypes.left, _
1, _
bounds.right)
mView.AddConstraint(right)
Dim bottom As New iOSLayoutConstraint(ctrl, _
iOSLayoutConstraint.AttributeTypes.bottom, _
iOSLayoutConstraint.RelationTypes.Equal, _
mView, _
iOSLayoutConstraint.AttributeTypes.top, _
1, _
bounds.bottom)
mView.AddConstraint(bottom)
mView.AddControl(ctrl)
End Sub
[/code]
Use like:
dim r as new iOSRectangle
r.FillColor = color.Blue
self.AddControlWithBounds(r,new xojo.Core.Rect(50,50,50,50))