iOSControlExtension - UBogun/Xojo-iosLib GitHub Wiki

iOSControlExtension extends every iOSControl with some frequently used UIView methods and properties and gives access to the underlying UIView/AppleView class instance.

General information

Definitions of enumerations, explanations of animations, other methods and properties are available under UIView Basics and the subsections listed there.
If you want to design your own custom control, use the iOSLibCanvas custom control as base that gives you access to all the available class events.

Properties

Being a module, the properties are only "virtual" properties being realized via methods, which means you cannot view them in debugger. You can if you copy the View As AppleView representation before returning to the debugger.

Alpha As Double: Sets the alpha value, that is, the transparency of the view. 0 is fully transparent and 1 fully opaque.

BackgroundColor As Color: Sets the background color of the view. Only visible if it is not fully filled with opaque content.

Bounds As Xojo.Core.Rect: The Bounds of the view, which means its dimensions normalized to its own coordinate system. Bounds, Center and Frame are connected to each other.

Center As Xojo.Core.Point: The center coordinates of the view in relation to its superview.

ClipsToBounds As Boolean: If true, the view's border clips the image. If false, it may overlap.

CoreAnimationLayer As AppleCALayer (read-only): Shortcut to the layer property of the view.

ExclusiveTouch As Boolean: If you want your control to process every Touch event itself and not forward it to embedded subviews/subcontrols, set this property to True.

FittingSize As Size (read-only): Returns the Size that the view needs for fully displaying its contents. See SizeToFit.

Frame As Xojo.Core.Rect: The Frame of the view, which means its dimensions in relation to its superview's coordinate system. Bounds, Center and Frame are connected to each other.

Opaque As Boolean: Defines if a control is opaque (= has no transparent content). Use this property to speed up drawing of fully opaque controls.

View As AppleView: Gives access to the AppleView instance of the control.

Tintcolor As Color: the first nondefault tint color value in the view's hierarchy, starting with the view itself.

Methods

AnimateAlpha (NewAlpha As Double, opt. Seconds as double = 0.2, opt. Curve as ioslibview.UIVIewAnimationCurve = ioslibview.UIVIewAnimationCurve.EaseInEaseOut): Triggers a block animation for the alpha property, in other words, transforms Alpha to NewAlpha over a duration of Seconds.

AnimateBackgroundColor (Newcolor As Color, opt. Seconds as double = 0.2, opt. Curve as ioslibview.UIVIewAnimationCurve = ioslibview.UIVIewAnimationCurve.EaseInEaseOut): Triggers a block animation for the backgroundcolor, in other words, transforms the backgroundcolor to Newcolor over a duration of Seconds. On some UIVIew types, this animation is performed instantaneously (no animation but rather a change).

AnimateBlock (ChangeBlock As AppleBlock, opt. Seconds as double = 0.2, opt. Curve as ioslibview.UIVIewAnimationCurve = ioslibview.UIVIewAnimationCurve.EaseInEaseOut): Use a custom block to perform operations on any control you like by changing their animatable properties to new values.

AnimateBounds (NewBounds As Xojo.Core.Rect, opt. Seconds as double = 0.2, opt. Curve as ioslibview.UIVIewAnimationCurve = ioslibview.UIVIewAnimationCurve.EaseInEaseOut): Triggers a Bounds animation.

AnimateCenter (NewX as Double, NewY as Double, opt. Seconds as double = 0.2, opt. Curve as ioslibview.UIVIewAnimationCurve = ioslibview.UIVIewAnimationCurve.EaseInEaseOut): Triggers a Center animation.

AnimateFrame (NewFrame As Xojo.Core.Rect, opt. Seconds as double = 0.2, opt. Curve as ioslibview.UIVIewAnimationCurve = ioslibview.UIVIewAnimationCurve.EaseInEaseOut): Triggers a Frame animation.

AnimateScale (XScale As Double, opt. YScale As Double, opt. Seconds as double = 0.2, opt. Curve as ioslibview.UIVIewAnimationCurve = ioslibview.UIVIewAnimationCurve.EaseInEaseOut): Triggers a Transform animation that scales the optical appearance of the view. Makes it proportional if you do not define YSCale.

AnimateSize (Width As Double, Height As Double, opt. Seconds as double = 0.2, opt. Curve as ioslibview.UIVIewAnimationCurve = ioslibview.UIVIewAnimationCurve.EaseInEaseOut): Triggers a block animation for the Bounds of the view.

AnimateTransform (aTransform As CGAffineTransform, opt. Seconds as double = 0.2, opt. Curve as ioslibview.UIVIewAnimationCurve = ioslibview.UIVIewAnimationCurve.EaseInEaseOut): Triggers a block animation for the Transform property of the View.

ConvertPointFromView (aPoint As Xojo.Core.Point, aView As AppleView) As Xojo.Core.Point: Converts a point from the coordinate space of the control to the specified coordinate space. ConvertPointFromControl (aPoint as Xojo.Core.Point, aControl As iOSControl) As Xojo.Core.Point: Shortcut for the method above, passing aControl.view to the first.

ConvertPointToView (aPoint As Xojo.Core.Point, aView As AppleView) As Xojo.Core.Point: Converts a point from the coordinate space of the current view to the specified coordinate space.
ConvertPointToControl (aPoint as Xojo.Core.Point, aControl As iOSControl) As Xojo.Core.Point: Shortcut for the method above, passing aControl.view to the first.

ConvertRectFromView (aRect As Xojo.Core.Rect, aView As AppleView) As Xojo.Core.Rect: Converts a rectangle from the specified coordinate space to the coordinate space of the current view.
ConvertRectFromControl (aRect As Xojo.Core.Rect, aControl As iOSControl) As Xojo.Core.Rect: Shortcut for the method above, passing aControl.view to the first.

ConvertRectToView (aRect As Xojo.Core.Rect, aView As AppleView) As Xojo.Core.Rect: Converts a rectangle from the coordinate space of the current view to the specified coordinate space.
ConvertRectFromControl (aRect As Xojo.Core.Rect, aControl As iOSControl) As Xojo.Core.Rect: Shortcut for the method above, passing aControl.view to the first.

FadeIn (opt. Seconds as double = 0.2, opt. Curve as ioslibview.UIVIewAnimationCurve = ioslibview.UIVIewAnimationCurve.EaseInEaseOut): Changes the Alpha value of the view to 1 – makes it fully opaque – during a time period of Seconds.

FadeOut (opt. Seconds as double = 0.2, opt. Curve as ioslibview.UIVIewAnimationCurve = ioslibview.UIVIewAnimationCurve.EaseInEaseOut): Changes the Alpha value of the view to 0 – makes it fully transparent – during a time period of Seconds.

InvertTransformation() Inverts the current Transform property of the view.

MoveTo (X As Double, Y As Double, opt. Seconds as double = 0.2, opt. Curve as ioslibview.UIVIewAnimationCurve = ioslibview.UIVIewAnimationCurve.EaseInEaseOut): Smoothly moves the control via block animation to the new position.

Redraw(): Lets the view recalculate its display immediately.

ResetTransformation Sets the Transform property to identity, which means, the view contents display is back to original.

Rotate (Angle As Double): This methods name may be a bit misleading. A view has no rotation property. This method transforms the current transform property with a rotation around Angle Degrees. See SetRotation.

Scale (XFactor As Double, opt. YFactor As Double = 0): Transforms the current Transform property with a scale factor in x/y direction. If you supply no YFactor value (or 0), the content is scaled proportionally by XFactor. See SetScale.

SetRotation (Angle As Double): In contrast to Rotate, the current Transform value is disregarded and replaced by a CGAffineTransform for just the rotation.

SetScale (XFactor As Double, opt. YFactor As Double = 0): Like above, scales the content by setting up a Transform Value for the scale factor(s).

SetTranslation (DeltaX As Double, DeltaY As Double): Sets the Transform property for a translation (an instance move) in DeltaX, DeltaY distance to the base values. See Translate

SizeToFit Resizes the control to its minimum value with respect to its contents. Very useful for resizing buttons!

SpringAnimateAlpha (newAlpha as Double, Seconds as double = 0.2, curve as ioslibview.UIVIewAnimationCurve = ioslibview.uiviewanimationcurve.EaseInEaseOut, DampingRatio as Double = 1, Velocity As Double = 1): Performs a SpringAnimation on the Alpha property.

SpringAnimateBackgroundColor (newcolor as color, Seconds as double = 0.2, curve as ioslibview.UIVIewAnimationCurve = ioslibview.uiviewanimationcurve.EaseInEaseOut, DampingRatio as Double = 1, Velocity As Double = 1): Performs a SpringAnimation on the BackgroundColor property.

SpringAnimateBlock (ChangeBlock As AppleBlock, opt. Seconds as double = 0.2, curve as ioslibview.UIVIewAnimationCurve = ioslibview.uiviewanimationcurve.EaseInEaseOut, DampingRatio as Double = 1, Velocity As Double = 1): Use a custom block to perform spring animations on any control you like by changing their animatable properties to new values.

SpringAnimateBounds (NewBounds As Xojo.Core.Rect, Seconds as double = 0.2, curve as ioslibview.UIVIewAnimationCurve = ioslibview.uiviewanimationcurve.EaseInEaseOut, DampingRatio as Double = 1, Velocity As Double = 1): Performs a SpringAnimation on the control's Bounds.

SpringAnimateCenter (NewX as Double, NewY as Double, Seconds as double = 0.2, curve as ioslibview.UIVIewAnimationCurve = ioslibview.uiviewanimationcurve.EaseInEaseOut, DampingRatio as Double = 1, Velocity As Double = 1): Performs a SpringAnimation on the control's Center.

SpringAnimateFrame (NewFrame As Xojo.Core.Rect, Seconds as double = 0.2, curve as ioslibview.UIVIewAnimationCurve = ioslibview.uiviewanimationcurve.EaseInEaseOut, DampingRatio as Double = 1, Velocity As Double = 1): Performs a SpringAnimation on the control's Frame.

SpringAnimateScale (XScale as Double, opt. YScale as Double, Seconds as double = 0.2, curve as ioslibview.UIVIewAnimationCurve = ioslibview.uiviewanimationcurve.EaseInEaseOut, DampingRatio as Double = 1, Velocity As Double = 1): Performs a SpringAnimation on the control's Transform to scale the control, proportionally if yscale = 0.

SpringAnimateSize (width as Double, height as Double, Seconds as double = 0.2, curve as ioslibview.UIVIewAnimationCurve = ioslibview.uiviewanimationcurve.EaseInEaseOut, DampingRatio as Double = 1, Velocity As Double = 1): Performs a SpringAnimation on the control's Bounds.

SpringAnimateTransform (aTransform as CGAffineTransform, Seconds as double = 0.2, curve as ioslibview.UIVIewAnimationCurve = ioslibview.uiviewanimationcurve.EaseInEaseOut, DampingRatio as Double = 1, Velocity As Double = 1): Performs a SpringAnimation on the Transform property.

SpringMoveTo (x as Double, y as Double, Seconds as double = 0.2, curve as ioslibview.UIVIewAnimationCurve = ioslibview.uiviewanimationcurve.EaseInEaseOut, DampingRatio as Double = 1, Velocity As Double = 1): Performs a Springanimation on the control's frame – in other words, moves it.

Transition (Transition as UIViewAnimationTransition, options as AppleViewAnimationOption, Seconds as Double = 0.2, Curve as UIVIewAnimationCurve = uiviewanimationcurve.EaseInEaseOut): Creates a view transition without changing other animatable properties.

TransitionToView (newview as appleview, transition as appleview.uiviewanimationtransition, options as AppleViewAnimationOption, Seconds as double = 0.2, curve as appleview.UIViewAnimationCurve = appleview.UIViewAnimationCurve.EaseInEaseOut): Creates a transition animation between the view and NewView using the given parameters.

TransitionWithAlpha (newAlpha as double, transition as appleview.uiviewanimationtransition, Seconds as double = 0.2, curve as appleview.UIViewAnimationCurve = appleview.UIViewAnimationCurve.EaseInEaseOut): Creates an Alpha transition animation for the view.

TransitionWithBackgroundColor (NewColor as Color, transition as appleview.uiviewanimationtransition, Seconds as double = 0.2, curve as appleview.UIViewAnimationCurve = appleview.UIViewAnimationCurve.EaseInEaseOut): Creates a BackgroundColor transition animation for the view.

TransitionWithBlock (Block as AppleBlock, transition as appleview.uiviewanimationtransition, Seconds as double = 0.2, curve as appleview.UIViewAnimationCurve = appleview.UIViewAnimationCurve.EaseInEaseOut): Creates a transition animation while performing the code within Block for the view.

TransitionWithBounds (NewBounds as Xojo.Core.Rect, transition as appleview.uiviewanimationtransition, Seconds as double = 0.2, curve as appleview.UIViewAnimationCurve = appleview.UIViewAnimationCurve.EaseInEaseOut): Creates a Bounds transition animation for the view.

TransitionWithCenter (NewX as Double, NewY as Double, transition as appleview.uiviewanimationtransition, Seconds as double = 0.2, curve as appleview.UIViewAnimationCurve = appleview.UIViewAnimationCurve.EaseInEaseOut): Creates a Center transition animation for the view.

TransitionWithFrame (NewFrame as Xojo.Core.Rect, transition as appleview.uiviewanimationtransition, Seconds as double = 0.2, curve as appleview.UIViewAnimationCurve = appleview.UIViewAnimationCurve.EaseInEaseOut): Creates a Frame transition animation scaling the view.

TransitionWithScale (XSCale as Double, YScale as Double, transition as appleview.uiviewanimationtransition, Seconds as double = 0.2, curve as appleview.UIViewAnimationCurve = appleview.UIViewAnimationCurve.EaseInEaseOut): Creates a Transform transition animation scaling the view (proportionally if YScale = 0).

TransitionWithSize (Width as Double, Height as Double, transition as appleview.uiviewanimationtransition, Seconds as double = 0.2, curve as appleview.UIViewAnimationCurve = appleview.UIViewAnimationCurve.EaseInEaseOut): Creates a Bounds transition animation resizing the view.

TransitionWithTransform (Transform As CGAffineTransform, transition as appleview.uiviewanimationtransition, Seconds as double = 0.2, curve as appleview.UIViewAnimationCurve = appleview.UIViewAnimationCurve.EaseInEaseOut): Creates a Transform transition animation.

Translate (DeltaX As Double, DeltaY As Double): Transforms the Transform property with a translation (move) in DeltaX, DeltaY distance.