Class: MPVolumeView

Inherits:
UIView show all

Overview

Use a volume view to present the user with a slider control for setting the system audio output volume, and a button for choosing the audio output route. When first displayed, the slider’s position reflects the current system audio output volume. As the user drags the slider, the changes update the volume. If the user presses the device volume buttons while sound is playing, the slider moves to reflect the new volume.

Instance Attribute Summary (collapse)

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 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:, #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) showsRouteButton

Determines whether or not the route button is visible in the volume view. The route button is visible by default when there is more than one audio output route available. To hide the route button, set this property’s value to NO.

Returns:

  • (Boolean)

- (Boolean) showsVolumeSlider

Determines whether or not the volume slider is visible in the volume view. The volume slider is visible by default. To hide the volume slider, set this property’s value to NO.

Returns:

  • (Boolean)

Instance Method Details

- (UIImage) maximumVolumeSliderImageForState(state)

Returns the maximum volume image associated with the specified control state. For a description of slider and thumb images, see “Customizing the Volume Slider’s Appearance.”

Parameters:

  • state (UIControlState)

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

Returns:

  • (UIImage)

    The maximum volume 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.

- (UIImage) minimumVolumeSliderImageForState(state)

Returns the minimum volume image associated with the specified control state. For a description of slider and thumb images, see “Customizing the Volume Slider’s Appearance.”

Parameters:

  • state (UIControlState)

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

Returns:

  • (UIImage)

    The maximum volume 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.

- (UIImage) routeButtonImageForState(state)

Returns the button image associated with the specified control state. Use this method to retrieve the corresponding button image for a specific 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 button 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.

- (CGRect) routeButtonRectForBounds(bounds)

Returns the drawing rectangle for the route button. Use this method to retieve the bounding rectangle for the route button.

Parameters:

  • bounds (CGRect)

    The bounding rectangle of the receiver.

Returns:

  • (CGRect)

    The computed drawing rectangle for the route button.

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

Assigns a maximum volume slider 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 capInsets property. For more information about how this value defines the regions of the slider, see the UIImage Class Reference.For a description of slider and thumb images, see “Customizing the Volume Slider’s Appearance.”

Parameters:

  • image (UIImage)

    The maximum volume slider image to associate with the specified states.

  • state (UIControlState)

    The control state with which to associate the image.

Returns:

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

Assigns a minimum volume slider 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 capInsets property. For more information about how this value defines the regions of the slider, see the UIImage Class Reference.For a description of slider and thumb images, see “Customizing the Volume Slider’s Appearance.”

Parameters:

  • image (UIImage)

    The minimum volume slider image to associate with the specified states.

  • state (UIControlState)

    The control state with which to associate the image.

Returns:

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

Assigns a button image to the specified control states. Use this to customize the appearance of the route button when it is enabled, disbaled, highlighted, and so on.

Parameters:

  • image (UIImage)

    The image to associate with the specified states.

  • state (UIControlState)

    The control state with which to associate the image.

Returns:

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

Assigns a thumb image to the specified control states. For a description of slider and thumb images, see “Customizing the Volume Slider’s Appearance.”

Parameters:

  • image (UIImage)

    The thumb image to associate with the specified states.

  • state (UIControlState)

    The control state with which to associate the image.

Returns:

- (CGSize) sizeThatFits(size)

Calculates and returns a size that best fits the receiver’s subviews. This method overrides the like-named method from the UIView class. It returns the preferred size the volume view needs to display the contained slider. You should not need to override this method.

Parameters:

  • size (CGSize)

    The preferred size of the receiver.

Returns:

  • (CGSize)

    A new size that fits the receiver’s subviews.

- (CGRect) volumeSliderRectForBounds(bounds)

Returns the drawing rectangle for the slider’s track. 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 volume slider track. This rectangle corresponds to the entire length of the track between the minimum and maximum value images.

- (UIImage) volumeThumbImageForState(state)

Returns the thumb image associated with the specified control state. For a description of slider and thumb images, see “Customizing the Volume Slider’s Appearance.”

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.

- (CGRect) volumeThumbRectForBounds(bounds, volumeSliderRect:rect, value:value)

Returns the drawing rectangle for the volume slider’s thumb image.

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 volumeSliderRectForBounds: method.

  • value (Float)

    The current value of the volume slider.

Returns:

  • (CGRect)

    The computed drawing rectangle for the thumb image.