Class

iOSCanvas


Warning

This item was deprecated in version 2020r2. Please use MobileCanvas as a replacement.

Description

Used to draw graphics.

Events

Name

Parameters

Returns

AppearanceChanged

dark As Boolean

Close

Open

Paint

g As iOSGraphics

PointerDown

pos As Point, eventInfo As PointerEvent

PointerDrag

pos As Point, eventInfo As PointerEvent

PointerUp

pos As Point, eventInfo As PointerEvent

Property descriptions


iOSCanvas.AccessibilityHint

AccessibilityHint As Text

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 view."

iOSCanvas.AccessibilityLabel

AccessibilityLabel As Text

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

Me.AccessibilityLabel = "Calculate the value."

iOSCanvas.Height

Height As Double

The height of the control.

This property is read-only.


iOSCanvas.Left

Left As Double

The left position of the control.

This property is read-only.


iOSCanvas.Name

Name As Text

The name of the control. This can only be set in the Inspector. Use the name to refer to the control.

This property is read-only.


iOSCanvas.Parent

Parent As iOSControl

Indicates the control's parent object, if it has one. If there is no parent, this is Nil.

This property is read-only.


iOSCanvas.Top

Top As Double

The top position of the control.

This property is read-only.


iOSCanvas.Visible

Visible As Boolean

Indicates whether the control is visible.

Make a button invisible:

Button1.Visible = False

iOSCanvas.Width

Width As Double

The width of the control.

This property is read-only.

Method descriptions


iOSCanvas.AddConstraint

AddConstraint(constraint As iOSLayoutConstraint)

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


iOSCanvas.AddControl

AddControl(child As MobileControl)

Adds a child control to the control.


iOSCanvas.Control

Control(index As Integer) As MobileControl

Gets the child control at the specified index.


iOSCanvas.ControlCount

ControlCount As Integer

The number of child controls in the control.


iOSCanvas.Handle

Handle As Ptr

The handle is used to get a reference to the control for interfacing directly with the iOS API.


iOSCanvas.Invalidate

Invalidate

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

Call Invalidate to force a Canvas to redraw itself:

Canvas1.Invalidate

iOSCanvas.RemoveConstraint

RemoveConstraint(constraint As iOSLayoutConstraint)

Removes a constraint from the control.


iOSCanvas.RemoveControl

RemoveControl(child As MobileControl)

Removes the control from the control.


iOSCanvas.SetTintColor

SetTintColor(value As Color)

Changes a control's tint color. This varies by control and for some controls may not do anything. For example, with an MobileTextField this changes the cursor color.

Event descriptions


iOSCanvas.AppearanceChanged

AppearanceChanged(dark As Boolean)

Called when a user switches between Light and Dark mode.

Use this event to update any graphics or other UI as needed.


iOSCanvas.Close

Close

Called when the control is removed from its container, such as a view.


iOSCanvas.Open

Open

Called after the control is created. This is where you typically put initialization code.

Set label text in Open event:

Me.Text = "Hello"

iOSCanvas.Paint

Paint(g As iOSGraphics)

Called when the Canvas needs to update its graphical display.

To draw a blue rectangle in the Canvas:

g.FillColor = Color.RGB(0, 0, 255)
g.FillRect(0, 0, g.Width, g.Height)

iOSCanvas.PointerDown

PointerDown(pos As Point, eventInfo As PointerEvent)

Called when the pointing device is tapped, touched or clicked.

This code saves all touch points to an array, which is used to display circles in the Paint event:

' mTouches is a property
' mTouches() As Point

If eventInfo.PointerCount > 0 Then
  ' Save multi-touch points
  For i As Integer = 0 To eventInfo.PointerCount - 1
    mTouches.Append(eventInfo.PointerPosition(i))
  Next
Else
  mTouches.Append(pos)
End If

Me.Invalidate

This code goes in the Paint event handler:

For Each p As Point In mTouches
  g.FillColor = Color.Blue
  g.FillOval(p.X, p.Y, 10, 10)
Next

iOSCanvas.PointerDrag

PointerDrag(pos As Point, eventInfo As PointerEvent)

Called when the pointing device is dragged.

Saves the drag positions to draw as circles:

' mTouches is a property
' mTouches() As Point

mTouches.Append(pos)
Me.Invalidate

iOSCanvas.PointerUp

PointerUp(pos As Point, eventInfo As PointerEvent)

Called when the pointing device is raised or released.

This code saves all touch points in an array where circles are displayed:

' mTouches is a property
' mTouches() As Point

If eventInfo.PointerCount > 0 Then
  ' Save multi-touch points
  For i As Integer = 0 To eventInfo.PointerCount - 1
    mTouches.Append(eventInfo.PointerPosition(i))
  Next
Else
  mTouches.Append(pos)
End If
Me.Invalidate

Compatibility

iOS projects on the iOS operating system.

See also

MobileControl parent class; PointerEvent, iOSGraphics classes