SegmentedControl


super: UISegmentedControl on iOS

A SegmentedControl object is a horizontal control made of multiple segments, each segment functioning as a discrete button. A segmented control affords a compact means to group together a number of controls. A segmented control can display a title (an String object) or an image (Image object). The SegmentedControl object automatically resizes segments to fit proportionally within their superview unless they have a specific width set. When you add and remove segments, you can request that the action be animated with sliding and fading effects.

SegmentedControl

Events

  • Load() This event is called when the object becames available in the current runtime system.

  • Unload() This event is called when the object has been removed from the current runtime system (but not yet deallocated).

Properties

  • var numberOfSegments: Int Returns the number of segments the receiver has. (read-only)

  • var index: Int The index number identifying the selected segment (you can set this property to select an item by its index).

  • var momentary: Bool A Boolean value that determines whether segments in the receiver show selected state.

  • var adjustWidthsByContent: Bool Indicates whether the control attempts to adjust segment widths based on their content widths.

  • var items: List Array of items presented by the SegmentedControl.

Methods

  • func removeAllItems() Removes all items of the receiver.

  • func insertItem(item: SegmentedControlItem, index: Int, animated: Bool = true) Inserts the item at the specified position, optionally animating the transition.

  • func addItem(item: SegmentedControlItem, animated: Bool = true) Inserts the item at the end of the existing items, optionally animating the transition.

  • func removeItemAtIndex(index: Int, animated: Bool = true) Removes the specified item, optionally animating the transition.

  • func removeItem(item: SegmentedControlItem, animated: Bool = true) Removes the specified item, optionally animating the transition.

  • func animate(duration: Float, delay: Float, options: AnimationOption, closure: Closure, completion: Closure) Animate changes to one or more views using the specified duration, delay, options and completion handler.

  • func setFocus() Force focus to be set to the selected control. For TextField and TextView that means force Keyboard to appear.

  • func clearFocus() Clear focus from selected control

    Enumeration

      AnimationOption

      • .AllowAnimatedContent
      • .AllowUserInteraction
      • .Autoreverse
      • .BeginFromCurrentState
      • .CurveEaseIn
      • .CurveEaseInOut
      • .CurveEaseOut
      • .CurveLinear
      • .LayoutSubviews
      • .OverrideInheritedCurve
      • .OverrideInheritedDuration
      • .OverrideInheritedOptions
      • .Repeat
      • .ShowHideTransitionViews
      • .TransitionCrossDissolve
      • .TransitionCurlDown
      • .TransitionCurlUp
      • .TransitionFlipFromBottom
      • .TransitionFlipFromLeft
      • .TransitionFlipFromRight
      • .TransitionFlipFromTop
      • .TransitionNone


    
    			// How to programmatically add a new item:
    			
    			// create the new item
    			var newItem = SegmentedControlItem()
    			// set the title (or the image)
    			newItem.title = "Item Title"
    			
    			// add the closure that will be called if the item is selected
    			var closure = func() { 
    				// your code here	
    			} 
    			newItem.bind("Action",closure)
    			
    			// add the new item to your SegmentedControl, in this case SegmentedControl1
    			SegmentedControl1.addItem(newItem)