Class: MPVolumeView
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)
-
- showsRouteButton
Determines whether or not the route button is visible in the volume view.
-
- showsVolumeSlider
Determines whether or not the volume slider is visible in the volume view.
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)
-
- maximumVolumeSliderImageForState:
Returns the maximum volume image associated with the specified control state.
-
- minimumVolumeSliderImageForState:
Returns the minimum volume image associated with the specified control state.
-
- routeButtonImageForState:
Returns the button image associated with the specified control state.
-
- routeButtonRectForBounds:
Returns the drawing rectangle for the route button.
-
- setMaximumVolumeSliderImage:forState:
Assigns a maximum volume slider image to the specified control states.
-
- setMinimumVolumeSliderImage:forState:
Assigns a minimum volume slider image to the specified control states.
-
- setRouteButtonImage:forState:
Assigns a button image to the specified control states.
-
- setVolumeThumbImage:forState:
Assigns a thumb image to the specified control states.
-
- sizeThatFits:
Calculates and returns a size that best fits the receiver’s subviews.
-
- volumeSliderRectForBounds:
Returns the drawing rectangle for the slider’s track.
-
- volumeThumbImageForState:
Returns the thumb image associated with the specified control state.
-
- volumeThumbRectForBounds:volumeSliderRect:value:
Returns the drawing rectangle for the volume slider’s thumb image.
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.
- (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.
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.”
- (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.”
- (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.
- (CGRect) routeButtonRectForBounds(bounds)
Returns the drawing rectangle for the route button. Use this method to retieve the bounding 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.”
- (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.”
- (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.
- (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.”
- (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.
- (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.
- (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.”
- (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.