Class

iOSMobileUserControl


Description

Used to embed UIViews created via declares into the Xojo control hierarchy.

Properties

Name

Type

Read-Only

Shared

AccessibilityHint

String

AccessibilityLabel

String

ControlCount

Integer

Enabled

Boolean

Height

Integer

Left

Integer

Name

String

Parent

MobileUIControl

TintColor

ColorGroup

Top

Integer

Visible

Boolean

Width

Integer

Methods

Name

Parameters

Returns

Shared

AddConstraint

constraint As iOSLayoutConstraint, name As String = ""

AddControl

child As MobileUIControl, isBeingAdded As Boolean = False

ClearFocus

Constraint

name As String

iOSLayoutConstraint

ControlAt

index As Integer

MobileUIControl

Controls

Iterable

Handle

Ptr

Refresh

RemoveConstraint

constraint As iOSLayoutConstraint

name As String

RemoveControl

child As MobileUIControl

SetFocus

Events

Name

Parameters

Returns

AppearanceChanged

dark As Boolean

Closing

CreateView

Ptr

DrawControlInLayoutEditor

g As Graphics

Opening

Constants

These constants are designed to be used with the MobileUIControl to show icons at the Navigator and Library.

Name

Description

NavigatorIcon

This constant is used to override the icon of your control in the Navigator. Using the WebSDKIconConverter, place the Base64 icon data into the value of this constant.

LibraryIcon

This constant is used to override the icon of your control in the Library. Using the WebSDKIconConverter, place the Base64 icon data into the value of this constant.

Property descriptions


iOSMobileUserControl.AccessibilityHint

AccessibilityHint As String

The accessibility hint is a longer description that is read aloud when VoiceOver is enabled.

Me.AccessibilityHint = "Click to calculate the value and display the next screen."

iOSMobileUserControl.AccessibilityLabel

AccessibilityLabel As String

The accessibility label of of a control is a short name that is read aloud when VoiceOver is enabled.

Me.AccessibilityLabel = "Calculate the value."

iOSMobileUserControl.ControlCount

ControlCount As Integer

The number of child controls in the control.

This property is read-only.


iOSMobileUserControl.Enabled

Enabled As Boolean

Indicates whether the control is enabled or disabled.

Disable the button:

Button1.Enabled = False

iOSMobileUserControl.Height

Height As Integer

The height of the control.

This property is read-only.


iOSMobileUserControl.Left

Left As Integer

The left position of the control.

This property is read-only.


iOSMobileUserControl.Name

Name As String

The name of the control.

This property is read-only.


iOSMobileUserControl.Parent

Parent As MobileUIControl

The parent (sometimes called a "Super") class of the control.

This property is read-only.


iOSMobileUserControl.TintColor

TintColor As ColorGroup

Changes a control's tint color.

On iOS, the following controls support TintColor:

Enum

Description

ProgressBar

The area indicating the value of the control will be drawn in the TintColor.

Slider

The area indicating the value of the control will be drawn in the TintColor.

TextArea

The cursor and text highlight color will be drawn in the TintColor.

TextField

The cursor and text highlight color will be drawn in the TintColor.


iOSMobileUserControl.Top

Top As Integer

The top position of the control.

This property is read-only.


iOSMobileUserControl.Visible

Visible As Boolean

Indicates whether the control is visible.

Make a button invisible:

Button1.Visible = False

iOSMobileUserControl.Width

Width As Integer

The width of the control.

This property is read-only.

Method descriptions


iOSMobileUserControl.AddConstraint

AddConstraint(constraint As iOSLayoutConstraint, name As String = "")

Adds a constraint to the control. The optional name parameter can be used to remove a constraint that was added via code.

This constraint is used by child controls that have been added to this control.


iOSMobileUserControl.AddControl

AddControl(child As MobileUIControl, isBeingAdded As Boolean = False)

Adds a child control to the control. When the value of isBeingAdded is True, the Opening event is triggered for the child control being added.


iOSMobileUserControl.ClearFocus

ClearFocus

Removes the focus from the control.

TextField1.ClearFocus

iOSMobileUserControl.Constraint

Constraint(name As String) As iOSLayoutConstraint

Gets a reference to a named constraint so that you can modify its settings in code.

Change an existing (and named) constraint of a control on the Screen:

' "TAWidth" is a width constraint for a TextField that has been given
' a name in the auto-layout Inspector properties.
Var c As iOSLayoutConstraint = Self.Constraint("TAWidth")
c.Offset = 200

iOSMobileUserControl.ControlAt

ControlAt(index As Integer) As MobileUIControl

Gets the child control at the specified index.


iOSMobileUserControl.Controls

Controls As Iterable

Allows you to iterate through all the controls that have been added to this control.


iOSMobileUserControl.Handle

Handle As Ptr

The handle to the underlying native OS control.


iOSMobileUserControl.Refresh

Refresh

Marks the control so that it will be redrawn during the next event loop.

Call Refresh to force a Canvas to redraw itself:

Canvas1.Refresh

iOSMobileUserControl.RemoveConstraint

RemoveConstraint(constraint As iOSLayoutConstraint)

Removes a constraint from the control.


RemoveConstraint(name As String)

Removes the constraint with the name passed from the Screen.


iOSMobileUserControl.RemoveControl

RemoveControl(child As MobileUIControl)

Removes the control from the control.


iOSMobileUserControl.SetFocus

SetFocus

Sets the focus to the control.

TextField1.SetFocus

Event descriptions


iOSMobileUserControl.AppearanceChanged

AppearanceChanged(dark As Boolean)

Raised when the appearance of the OS changes between light and dark mode.


iOSMobileUserControl.Closing

Closing

Called when the control's layout is closing.


iOSMobileUserControl.CreateView

CreateView As Ptr

Raised when the control needs you to create your UIView. Return the pointer to the UIView.

See Apple's documentation for more information about UIView.


iOSMobileUserControl.DrawControlInLayoutEditor

DrawControlInLayoutEditor(g As Graphics)

This event allows you to draw a preview of your control in the Layout Editor, similar to how the control will look like in at runtime. As this code will run as a script in the IDE, if it doesn't compile for any reason, you will see what happened in the Messages pane.

This event fires whenever your control needs to be drawn in the Layout Editor.

There is no need to re-open the project or restart the IDE, in order to see changes you make to the code in this event.

For more information of how this works, see Drawing Your Control.


iOSMobileUserControl.Opening

Opening

Called when the control's layout is opening.

This is where you typically put initialization code.

This example in the Opening event of a Label sets its text to "Hello":

Me.Text = "Hello"

Drawing Your Control

As for Xojo 2026r1 iOSMobileUserControl has the ability to draw itself in the Layout Editor using the same techniques that you use to draw a control in the Paint event of a Canvas control with one important difference: this event has access to the Properties and Constants of your class.

To draw a preview of your control in the Layout Editor, you must implement the DrawControlInLayoutEditor event. You may wish to implement it even if you're not using it to prevent this event from being available to the end users of your control. If the code you have placed in the event can't compile or runs into a runtime issue, an amber warning icon will be drawn on your control and the errors will be displayed to the Messages pane.

Important

Methods cannot be called in this event.

Here's an example of how you would draw a red oval within the bounds of the control:

g.DrawingColor = &cFF0000
g.DrawOval(0, 0, g.Width, g.Height)

In addition to the standard drawing controls, there are also some methods for accessing the properties and constants in your control.

Property Methods

BooleanProperty(Name as String) as Boolean

Gets the current value of a Boolean property of your control.


ColorProperty(name As String) As Color

Gets the current value of a Color property of your control.


DoubleProperty(name As String) As Double

Gets the current value of a Double property of your control.


IntegerProperty(name As String) As Integer

Gets the current value of an Integer property of your control.


PictureProperty(name As String) As Picture

Gets the current value of a Picture property of your control.


StringProperty(name As String) As String

Gets the current value of a String property of your control.

Constant Methods


ConstantValue(name As String) As String

Gets the value of a constant in your control as a String.

You can use the ConstantValue of a string stored in a constant, such as "kDescription".:

Var s As String = ConstantValue("kDescription")
g.DrawText(s, 25, 25)

PictureConstant(name As String) As Picture

Gets the value of a constant in your control as a Picture.

You can use PictureConstant with the Base64 value (without the type header) of a picture stored in a constant, such as "kIcon":

Var icon As Picture = PictureConstant("kIcon")
g.DrawPicture(icon, 0, 0)

Color Methods

ColorGroup.NamedColor(name As String) As Color

When running on a platform that supports named colors (only macOS at the time of this writing), this method returns the named OS.

Note

Color names are case sensitive, so the macOS secondary label color should be "secondaryLabelColor".


TextColor As Color

Returns the current text color of the platform that the IDE is running on.


FillColor As Color

Returns the current fill color of the platform that the IDE is running on.


IsDarkMode As Boolean

Returns True if the system is running in dark mode (only macOS at the time of this writing).

Font Methods

FontCount As Integer

Returns the number of fonts available on the system.


FontAt(index As Integer) As String

Returns the name of the font at the specified index.

Compatibility

Project Types

Mobile

Operating Systems

iOS

See also

MobileUIControl parent class