Class: UISlider

Inherits:
UIControl show all

Overview

A UISlider object is a visual control used to select a single value from a continuous range of values. Sliders are always displayed as horizontal bars. An indicator, or thumb, notes the current value of the slider and can be moved by the user to change the setting.

Instance Attribute Summary (collapse)

Attributes inherited from UIControl

#contentHorizontalAlignment, #contentVerticalAlignment, #enabled, #highlighted, #selected, #state, #touchInside, #tracking

Attributes inherited from UIView

#alpha, #autoresizesSubviews, #autoresizingMask, #backgroundColor, #bounds, #center, #clearsContextBeforeDrawing, #clipsToBounds, #contentMode, #contentScaleFactor, #exclusiveTouch, #frame, #gestureRecognizers, #hidden, #layer, #multipleTouchEnabled, #opaque, #restorationIdentifier, #subviews, #superview, #tag, #transform, #userInteractionEnabled, #window

Attributes inherited from UIResponder

#inputAccessoryView, #inputView, #undoManager

Instance Method Summary (collapse)

Methods inherited from UIControl

#actionsForTarget:forControlEvent:, #addTarget:action:forControlEvents:, #allControlEvents, #allTargets, #beginTrackingWithTouch:withEvent:, #cancelTrackingWithEvent:, #continueTrackingWithTouch:withEvent:, #endTrackingWithTouch:withEvent:, #removeTarget:action:forControlEvents:, #sendAction:to:forEvent:, #sendActionsForControlEvents:

Methods inherited from UIView

#addConstraint:, #addConstraints:, #addGestureRecognizer:, #addSubview:, #alignmentRectForFrame:, #alignmentRectInsets, animateWithDuration:animations:, animateWithDuration:animations:completion:, animateWithDuration:delay:options:animations:completion:, areAnimationsEnabled, beginAnimations:context:, #bringSubviewToFront:, commitAnimations, #constraints, #constraintsAffectingLayoutForAxis:, #contentCompressionResistancePriorityForAxis:, #contentHuggingPriorityForAxis:, #convertPoint:fromView:, #convertPoint:toView:, #convertRect:fromView:, #convertRect:toView:, #decodeRestorableStateWithCoder:, #didAddSubview:, #didMoveToSuperview, #didMoveToWindow, #drawRect:, #drawRect:forViewPrintFormatter:, #encodeRestorableStateWithCoder:, #endEditing:, #exchangeSubviewAtIndex:withSubviewAtIndex:, #exerciseAmbiguityInLayout, #frameForAlignmentRect:, #gestureRecognizerShouldBegin:, #hasAmbiguousLayout, #hitTest:withEvent:, #initWithFrame:, #insertSubview:aboveSubview:, #insertSubview:atIndex:, #insertSubview:belowSubview:, #intrinsicContentSize, #invalidateIntrinsicContentSize, #isDescendantOfView:, layerClass, #layoutIfNeeded, #layoutSubviews, #needsUpdateConstraints, #pointInside:withEvent:, #removeConstraint:, #removeConstraints:, #removeFromSuperview, #removeGestureRecognizer:, requiresConstraintBasedLayout, #sendSubviewToBack:, setAnimationBeginsFromCurrentState:, setAnimationCurve:, setAnimationDelay:, setAnimationDelegate:, setAnimationDidStopSelector:, setAnimationDuration:, setAnimationRepeatAutoreverses:, setAnimationRepeatCount:, setAnimationStartDate:, setAnimationTransition:forView:cache:, setAnimationWillStartSelector:, setAnimationsEnabled:, #setContentCompressionResistancePriority:forAxis:, #setContentHuggingPriority:forAxis:, #setNeedsDisplay, #setNeedsDisplayInRect:, #setNeedsLayout, #setNeedsUpdateConstraints, #setTranslatesAutoresizingMaskIntoConstraints:, #sizeThatFits:, #sizeToFit, #systemLayoutSizeFittingSize:, transitionFromView:toView:duration:options:completion:, transitionWithView:duration:options:animations:completion:, #translatesAutoresizingMaskIntoConstraints, #updateConstraints, #updateConstraintsIfNeeded, #viewForBaselineLayout, #viewPrintFormatter, #viewWithTag:, #willMoveToSuperview:, #willMoveToWindow:, #willRemoveSubview:

Methods inherited from UIResponder

#becomeFirstResponder, #canBecomeFirstResponder, #canPerformAction:withSender:, #canResignFirstResponder, #isFirstResponder, #motionBegan:withEvent:, #motionCancelled:withEvent:, #motionEnded:withEvent:, #nextResponder, #reloadInputViews, #remoteControlReceivedWithEvent:, #resignFirstResponder, #touchesBegan:withEvent:, #touchesCancelled:withEvent:, #touchesEnded:withEvent:, #touchesMoved:withEvent:

Methods inherited from NSObject

#!, #!=, #!~, #, #==, #===, #=~, #Rational, #__callee__, #__method__, #__send__, #__type__, `, alloc, allocWithZone:, #autoContentAccessingProxy, autoload, autoload?, autorelease_pool, #awakeAfterUsingCoder:, binding, block_given?, caller, cancelPreviousPerformRequestsWithTarget:, cancelPreviousPerformRequestsWithTarget:selector:object:, catch, class, classFallbacksForKeyedArchiver, #classForCoder, #classForKeyedArchiver, classForKeyedUnarchiver, #clone, conformsToProtocol:, #copy, copyWithZone:, #dealloc, #define_singleton_method, description, display, #doesNotRecognizeSelector:, #dup, #enum_for, #eql?, #equal?, #extend, fail, #finalize, format, #forwardInvocation:, #forwardingTargetForSelector:, framework, #freeze, #frozen?, getpass, gets, global_variables, #init, initialize, #initialize_clone, #initialize_copy, #initialize_dup, #inspect, instanceMethodForSelector:, instanceMethodSignatureForSelector:, #instance_eval, #instance_exec, #instance_of?, #instance_variable_defined?, #instance_variable_get, #instance_variable_set, #instance_variables, instancesRespondToSelector:, isSubclassOfClass:, #is_a?, iterator?, #kind_of?, lambda, load, load_bridge_support_file, load_plist, local_variables, loop, #method, #methodForSelector:, #methodSignatureForSelector:, #methods, #mutableCopy, mutableCopyWithZone:, new, #nil?, open, p, #performSelector:onThread:withObject:waitUntilDone:, #performSelector:onThread:withObject:waitUntilDone:modes:, #performSelector:withObject:afterDelay:, #performSelector:withObject:afterDelay:inModes:, #performSelectorInBackground:withObject:, #performSelectorOnMainThread:withObject:waitUntilDone:, #performSelectorOnMainThread:withObject:waitUntilDone:modes:, print, printf, #private_methods, proc, #protected_methods, #public_method, #public_methods, #public_send, putc, puts, raise, rand, readline, readlines, #replacementObjectForCoder:, #replacementObjectForKeyedArchiver:, require, resolveClassMethod:, resolveInstanceMethod:, #respond_to?, #respond_to_missing?, select, #send, setVersion:, #singleton_methods, sprintf, srand, superclass, #taint, #tainted?, #tap, test, throw, #to_plist, #to_s, trace_var, trap, #trust, #untaint, untrace_var, #untrust, #untrusted?, version

Constructor Details

This class inherits a constructor from NSObject

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class NSObject

Instance Attribute Details

- (Boolean) continuous

Contains a Boolean value indicating whether changes in the sliders value generate continuous update events. If YES, the slider sends update events continuously to the associated target’s action method. If NO, the slider only sends an action event when the user releases the slider’s thumb control to set the final value.The default value of this property is YES.

Returns:

  • (Boolean)

- (UIImage) currentMaximumTrackImage (readonly)

Contains the maximum track image currently being used to render the receiver. (read-only) Sliders can have different track images for different control states. The image associated with this property reflects the maximum track image associated with the currently active control state. To get the maximum track image for a different control state, use the maximumTrackImageForState: method.If no custom track images have been set using the setMaximumTrackImage:forState: method, this property contains the value nil. In that situation, the receiver uses the default maximum track image for drawing.

Returns:

- (UIImage) currentMinimumTrackImage (readonly)

Contains the minimum track image currently being used to render the receiver. (read-only) Sliders can have different track images for different control states. The image associated with this property reflects the minimum track image associated with the currently active control state. To get the minimum track image for a different control state, use the minimumTrackImageForState: method.If no custom track images have been set using the setMinimumTrackImage:forState: method, this property contains the value nil. In that situation, the receiver uses the default minimum track image for drawing.

Returns:

- (UIImage) currentThumbImage (readonly)

Contains the thumb image currently being used to render the receiver. (read-only) Sliders can have different thumb images for different control states. The image associated with this property reflects the thumb image associated with the currently active control state. To get the thumb image for a different control state, use the thumbImageForState: method.If no custom thumb images have been set using the setThumbImage:forState: method, this property contains the value nil. In that situation, the receiver uses the default thumb image for drawing.

Returns:

- (UIColor) maximumTrackTintColor

The color used to tint the standard maximum track images. Setting this property removes any custom maximum track images associated with the slider.

Returns:

- (Float) maximumValue

Contains the maximum value of the receiver. If you change the value of this property, and the current value of the receiver is above the new maximum, the current value is adjusted to match the new maximum value automatically.The default value of this property is 1.0.

Returns:

- (UIImage) maximumValueImage

Contains the image that is drawn on the side of the slider representing the maximum value. The image you specify should fit within the bounding rectangle returned by the maximumValueImageRectForBounds: method. If it does not, the image is scaled to fit. In addition, the receiver’s track is lengthened or shortened as needed to accommodate the image in its bounding rectangle. This default value of this property is nil.

Returns:

- (UIColor) minimumTrackTintColor

The color used to tint the standard minimum track images. Setting this property removes any custom minimum track images associated with the slider.

Returns:

- (Float) minimumValue

Contains the minimum value of the receiver. If you change the value of this property, and the current value of the receiver is below the new minimum, the current value is adjusted to match the new minimum value automatically.The default value of this property is 0.0.

Returns:

- (UIImage) minimumValueImage

Contains the image that is drawn on the side of the slider representing the minimum value. The image you specify should fit within the bounding rectangle returned by the minimumValueImageRectForBounds: method. If it does not, the image is scaled to fit. In addition, the receiver’s track is lengthened or shortened as needed to accommodate the image in its bounding rectangle. This default value of this property is nil.

Returns:

- (UIColor) thumbTintColor

The color used to tint the standard thumb images. Setting this property removes any custom thumb images associated with the slider.

Returns:

- (Float) value

Contains the receiver’s current value. Setting this property causes the receiver to redraw itself using the new value. To render an animated transition from the current value to the new value, you should use the setValue:animated: method instead.If you try to set a value that is below the minimum or above the maximum value, the minimum or maximum value is set instead. The default value of this property is 0.0.

Returns:

Instance Method Details

- (UIImage) maximumTrackImageForState(state)

Returns the maximum track image associated with the specified control state.

Parameters:

  • state (UIControlState)

    The control state whose maximum track image you want. You should specify only one control state value for this parameter.

Returns:

  • (UIImage)

    The maximum track image associated with the specified state, or nil if an appropriate image could not be retrieved. This method might return nil if you specify multiple control states in the state parameter. For a description of track images, see “Customizing the Slider’s Appearance.”

- (CGRect) maximumValueImageRectForBounds(bounds)

Returns the drawing rectangle for the maximum value image. You should not call this method directly. If you want to customize the rectangle in which the maximum value image is drawn, you can override this method and return a different rectangle.

Parameters:

  • bounds (CGRect)

    The bounding rectangle of the receiver.

Returns:

  • (CGRect)

    The computed drawing rectangle for the image.

- (UIImage) minimumTrackImageForState(state)

Returns the minimum track image associated with the specified control state.

Parameters:

  • state (UIControlState)

    The control state whose minimum track image you want. You should specify only one control state value for this parameter.

Returns:

  • (UIImage)

    The minimum track image associated with the specified state, or nil if no image has been set. This method might also return nil if you specify multiple control states in the state parameter. For a description of track images, see “Customizing the Slider’s Appearance.”

- (CGRect) minimumValueImageRectForBounds(bounds)

Returns the drawing rectangle for the minimum value image. You should not call this method directly. If you want to customize the rectangle in which the minimum value image is drawn, you can override this method and return a different rectangle.

Parameters:

  • bounds (CGRect)

    The bounding rectangle of the receiver.

Returns:

  • (CGRect)

    The computed drawing rectangle for the image.

- (Object) setMaximumTrackImage(image, forState:state)

Assigns a maximum track image to the specified control states. The orientation of the track image must match the orientation of the slider control. To facilitate the stretching of the image to fill the space between the thumb and end point, track images are usually defined in three regions. A stretchable region sits between two end cap regions. The end caps define the portions of the image that remain as is and are not stretched. The stretchable region is a 1-point wide area between the end caps that can be replicated to make the image appear longer. To define the end cap sizes for a horizontally-oriented slider, assign an appropriate value to the image’s leftCapWidth property. For more information about how this value defines the regions of the slider, see the UIImage class. Setting a new track image for any state clears any custom tint color you may have provided for maximum track images.

Parameters:

  • image (UIImage)

    The maximum track image to associate with the specified states.

  • state (UIControlState)

    The control state with which to associate the image.

Returns:

- (Object) setMinimumTrackImage(image, forState:state)

Assigns a minimum track image to the specified control states. The orientation of the track image must match the orientation of the slider control. To facilitate the stretching of the image to fill the space between the thumb and end point, track images are usually defined in three regions. A stretchable region sits between two end cap regions. The end caps define the portions of the image that remain as is and are not stretched. The stretchable region is a 1-point wide area between the end caps that can be replicated to make the image appear longer. To define the end cap sizes for a horizontally-oriented slider, assign an appropriate value to the image’s leftCapWidth property. For more information about how this value defines the regions of the slider, see the UIImage class. Setting a new track image for any state clears any custom tint color you may have provided for minimum track images.

Parameters:

  • image (UIImage)

    The minimum track image to associate with the specified states.

  • state (UIControlState)

    The control state with which to associate the image.

Returns:

- (Object) setThumbImage(image, forState:state)

Assigns a thumb image to the specified control states. Setting a new thumb image for any state clears any custom tint color you may have provided for thumb images.

Parameters:

  • image (UIImage)

    The thumb image to associate with the specified states.

  • state (UIControlState)

    The control state with which to associate the image.

Returns:

- (Object) setValue(value, animated:animated)

Sets the receiver’s current value, allowing you to animate the change visually. If you try to set a value that is below the minimum or above the maximum value, the minimum or maximum value is set instead. The default value of this property is 0.0.

Parameters:

  • value (Float)

    The new value to assign to the value property

  • animated (Boolean)

    Specify YES to animate the change in value when the receiver is redrawn; otherwise, specify NO to draw the receiver with the new value only. Animations are performed asynchronously and do not block the calling thread.

Returns:

- (UIImage) thumbImageForState(state)

Returns the thumb image associated with the specified control state.

Parameters:

  • state (UIControlState)

    The control state whose thumb image you want. You should specify only one control state value for this parameter.

Returns:

  • (UIImage)

    The thumb image associated with the specified state, or nil if an appropriate image could not be retrieved. This method might return nil if you specify multiple control states in the state parameter. For a description of track and thumb images, see “Customizing the Slider’s Appearance.”

- (CGRect) thumbRectForBounds(bounds, trackRect:rect, value:value)

Returns the drawing rectangle for the slider’s thumb image. You should not call this method directly. If you want to customize the thumb image’s drawing rectangle, you can override this method and return a different rectangle. The rectangle you return should reflect the size of your thumb image and its current position on the slider’s track.

Parameters:

  • bounds (CGRect)

    The bounding rectangle of the receiver.

  • rect (CGRect)

    The drawing rectangle for the receiver’s track, as returned by the trackRectForBounds: method.

  • value (Float)

    The current value of the slider.

Returns:

  • (CGRect)

    The computed drawing rectangle for the thumb image.

- (CGRect) trackRectForBounds(bounds)

Returns the drawing rectangle for the slider’s track. You should not call this method directly. If you want to customize the track rectangle, you can override this method and return a different rectangle. The returned rectangle is used to scale the track and thumb images during drawing.

Parameters:

  • bounds (CGRect)

    The bounding rectangle of the receiver.

Returns:

  • (CGRect)

    The computed drawing rectangle for the track. This rectangle corresponds to the entire length of the track between the minimum and maximum value images.