Class: UISlider
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)
-
- continuous
Contains a Boolean value indicating whether changes in the sliders value generate continuous update events.
-
- currentMaximumTrackImage
readonly
Contains the maximum track image currently being used to render the receiver.
-
- currentMinimumTrackImage
readonly
Contains the minimum track image currently being used to render the receiver.
-
- currentThumbImage
readonly
Contains the thumb image currently being used to render the receiver.
-
- maximumTrackTintColor
The color used to tint the standard maximum track images.
-
- maximumValue
Contains the maximum value of the receiver.
-
- maximumValueImage
Contains the image that is drawn on the side of the slider representing the maximum value.
-
- minimumTrackTintColor
The color used to tint the standard minimum track images.
-
- minimumValue
Contains the minimum value of the receiver.
-
- minimumValueImage
Contains the image that is drawn on the side of the slider representing the minimum value.
-
- thumbTintColor
The color used to tint the standard thumb images.
-
- value
Contains the receiver’s current value.
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)
-
- maximumTrackImageForState:
Returns the maximum track image associated with the specified control state.
-
- maximumValueImageRectForBounds:
Returns the drawing rectangle for the maximum value image.
-
- minimumTrackImageForState:
Returns the minimum track image associated with the specified control state.
-
- minimumValueImageRectForBounds:
Returns the drawing rectangle for the minimum value image.
-
- setMaximumTrackImage:forState:
Assigns a maximum track image to the specified control states.
-
- setMinimumTrackImage:forState:
Assigns a minimum track image to the specified control states.
-
- setThumbImage:forState:
Assigns a thumb image to the specified control states.
-
- setValue:animated:
Sets the receiver’s current value, allowing you to animate the change visually.
-
- thumbImageForState:
Returns the thumb image associated with the specified control state.
-
- thumbRectForBounds:trackRect:value:
Returns the drawing rectangle for the slider’s thumb image.
-
- trackRectForBounds:
Returns the drawing rectangle for the slider’s track.
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.
- (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.
- (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.
- (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.
- (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.
- (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.
- (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.
- (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.
- (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.
- (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.
- (UIColor) thumbTintColor
The color used to tint the standard thumb images. Setting this property removes any custom thumb images associated with the slider.
- (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.
Instance Method Details
- (UIImage) maximumTrackImageForState(state)
Returns the maximum track image associated with the specified control state.
- (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.
- (UIImage) minimumTrackImageForState(state)
Returns the minimum track image associated with the specified control state.
- (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.
- (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.
- (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.
- (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.
- (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.
- (UIImage) thumbImageForState(state)
Returns the thumb image associated with the specified control state.
- (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.
- (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.