Class: UIBarButtonItem

Inherits:
UIBarItem show all

Overview

A bar button item is a button specialized for placement on a UIToolbar or UINavigationBar object. It inherits basic button behavior from its abstract superclass, UIBarItem. The UIBarButtonItem defines additional initialization methods and properties for use on toolbars and navigation bars.

Direct Known Subclasses

MKUserTrackingBarButtonItem

Instance Attribute Summary (collapse)

Attributes inherited from UIBarItem

#enabled, #image, #imageInsets, #landscapeImagePhone, #landscapeImagePhoneInsets, #tag, #title

Instance Method Summary (collapse)

Methods inherited from UIBarItem

#setTitleTextAttributes:forState:, #titleTextAttributesForState:

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

- (Symbol) action

The selector defining the action message to send to the target object when the user taps this bar button item. If the value of this property is NULL, no action message is sent. The default value is NULL.

Returns:

- (UIView) customView

A custom view representing the item.

Returns:

- (NSSet) possibleTitles

The set of possible titles to display on the bar button. Use this property to provide a hint to the system on how to correctly size the bar button item to be wide enough to accommodate your widest title. Set the value of this property to an NSSet object containing all the titles you intend as possible titles for the bar button item. Use the actual text strings you intend to display.This property applies to bar button items placed on navigation bars or toolbars.

Returns:

- (UIBarButtonItemStyle) style

The style of the item. One of the constants defined in UIBarButtonItemStyle. The default value is UIBarButtonItemStylePlain.

- (Object) target

The object that receives an action when the item is selected. If nil, the action message is passed up the responder chain where it may be handled by any object implementing a method corresponding to the selector held by the action property. The default value is nil.

Returns:

- (UIColor) tintColor

The tint color for the button item.

Returns:

- (Float) width

The width of the item. If this property value is positive, the width of the combined image and title are fixed. If the value is 0.0 or negative, the item sets the width of the combined image and title to fit. This property is ignored if the style uses radio mode. The default value is 0.0.

Returns:

Instance Method Details

- (UIImage) backButtonBackgroundImageForState(state, barMetrics:barMetrics)

Returns the back button background image for a given control state and bar metrics. This modifier applies only to navigation bar back buttons and is ignored by other buttons.

Parameters:

  • state (UIControlState)

    A control state.

  • barMetrics (UIBarMetrics)

    Bar metrics.

Returns:

  • (UIImage)

    The back button background image for state and barMetrics.

- (Float) backButtonBackgroundVerticalPositionAdjustmentForBarMetrics(barMetrics)

Returns the back button vertical position offset for given bar metrics. This modifier applies only to navigation bar back buttons and is ignored by other buttons.This offset is used to adjust the vertical centering of bordered bar buttons within the bar.

Parameters:

Returns:

  • (Float)

    The back button vertical position offset for barMetrics.

- (UIOffset) backButtonTitlePositionAdjustmentForBarMetrics(barMetrics)

Returns the back button title offset for given bar metrics. This modifier applies only to navigation bar back buttons and is ignored by other buttons.

Parameters:

Returns:

  • (UIOffset)

    The back button title offset for barMetrics.

- (UIImage) backgroundImageForState(state, barMetrics:barMetrics)

Returns the background image for a given state and bar metrics.

Parameters:

  • state (UIControlState)

    A control state.

  • barMetrics (UIBarMetrics)

    Bar metrics.

Returns:

  • (UIImage)

    The background image for the button given state and metrics.

- (UIImage) backgroundImageForState(state, style:style, barMetrics:barMetrics)

Returns the background image for the specified state, style, and metrics.

Parameters:

Returns:

  • (UIImage)

    The background image associated with the specified state, style, and metrics.

- (Float) backgroundVerticalPositionAdjustmentForBarMetrics(barMetrics)

Returns the background vertical position offset for given bar metrics. This offset is used to adjust the vertical centering of bordered bar buttons within the bar.

Parameters:

Returns:

  • (Float)

    The background vertical position offset for barMetrics.

- (Object) initWithBarButtonSystemItem(systemItem, target:target, action:action)

Initializes a new item containing the specified system item.

Parameters:

  • systemItem (UIBarButtonSystemItem)

    The system item to use as the first item on the bar. One of the constants defined in UIBarButtonSystemItem.

  • target (Object)

    The object that receives the action message.

  • action (Symbol)

    The action to send to target when this item is selected.

Returns:

  • (Object)

    A newly initialized item containing the specified system item. The item’s target is nil.

- (Object) initWithCustomView(customView)

Initializes a new item using the specified custom view. The bar button item created by this method does not call the action method of its target in response to user interactions. Instead, the bar button item expects the specified custom view to handle any user interactions and provide an appropriate response.

Parameters:

  • customView (UIView)

    A custom view representing the item.

Returns:

  • (Object)

    Newly initialized item with the specified properties.

- (Object) initWithImage(image, landscapeImagePhone:landscapeImagePhone, style:style, target:target, action:action)

Initializes a new item using the specified images and other properties.

Parameters:

  • image (UIImage)

    The item’s image. If nil an image is not displayed.

  • landscapeImagePhone (UIImage)

    The image to be used for the item in landscape bars in the UIUserInterfaceIdiomPhone idiom.

  • style (UIBarButtonItemStyle)

    The style of the item. One of the constants defined in UIBarButtonItemStyle.

  • target (Object)

    The object that receives the action message.

  • action (Symbol)

    The action to send to target when this item is selected.

Returns:

  • (Object)

    A new item initialized to use using the specified images and other properties

- (Object) initWithImage(image, style:style, target:target, action:action)

Initializes a new item using the specified image and other properties.

Parameters:

  • image (UIImage)

    The item’s image. If nil an image is not displayed.The images displayed on the bar are derived from this image. If this image is too large to fit on the bar, it is scaled to fit. Typically, the size of a toolbar and navigation bar image is 20 x 20 points. The alpha values in the source image are used to create the images—opaque values are ignored.

  • style (UIBarButtonItemStyle)

    The style of the item. One of the constants defined in UIBarButtonItemStyle.

  • target (Object)

    The object that receives the action message.

  • action (Symbol)

    The action to send to target when this item is selected.

Returns:

  • (Object)

    Newly initialized item with the specified properties.

- (Object) initWithTitle(title, style:style, target:target, action:action)

Initializes a new item using the specified title and other properties.

Parameters:

  • title (String)

    The item’s title. If nil a title is not displayed.

  • style (UIBarButtonItemStyle)

    The style of the item. One of the constants defined in UIBarButtonItemStyle.

  • target (Object)

    The object that receives the action message.

  • action (Symbol)

    The action to send to target when this item is selected.

Returns:

  • (Object)

    Newly initialized item with the specified properties.

- (Object) setBackButtonBackgroundImage(backgroundImage, forState:state, barMetrics:barMetrics)

Sets the back button background image for a given control state and bar metrics This modifier applies only to navigation bar back buttons and is ignored by other buttons.For good results, backgroundImage must be a stretchable image.

Parameters:

  • backgroundImage (UIImage)

    The image to use for the back button’s background.

  • state (UIControlState)

    A control state.

  • barMetrics (UIBarMetrics)

    Bar metrics.

Returns:

- (Object) setBackButtonBackgroundVerticalPositionAdjustment(adjustment, forBarMetrics:barMetrics)

Sets the back button vertical position offset for given bar metrics. This modifier applies only to navigation bar back buttons and is ignored by other buttons.This offset is used to adjust the vertical centering of bordered bar buttons within the bar.

Parameters:

  • adjustment (Float)

    The back button vertical position offset for barMetrics.

  • barMetrics (UIBarMetrics)

    Bar metrics.

Returns:

- (Object) setBackButtonTitlePositionAdjustment(adjustment, forBarMetrics:barMetrics)

Sets the back button title offset for given bar metrics This modifier applies only to navigation bar back buttons and is ignored by other buttons.

Parameters:

  • adjustment (UIOffset)

    The back button title offset for barMetrics.

  • barMetrics (UIBarMetrics)

    Bar metrics.

Returns:

- (Object) setBackgroundImage(backgroundImage, forState:state, barMetrics:barMetrics)

Sets the background image for a given state and bar metrics. For good results, backgroundImage must be a stretchable image.

Parameters:

  • backgroundImage (UIImage)

    The background image for the specified state and metrics.

  • state (UIControlState)

    A control state.

  • barMetrics (UIBarMetrics)

    Bar metrics.

Returns:

- (Object) setBackgroundImage(backgroundImage, forState:state, style:style, barMetrics:barMetrics)

Sets the background image for the specified state, style, and metrics. For good results, backgroundImage must be a stretchable image.

Parameters:

  • backgroundImage (UIImage)

    The background image to use for the specified state, style, and metrics.

  • state (UIControlState)

    The bar button state.

  • style (UIBarButtonItemStyle)

    The bar button style.

  • barMetrics (UIBarMetrics)

    The bar button metrics.

Returns:

- (Object) setBackgroundVerticalPositionAdjustment(adjustment, forBarMetrics:barMetrics)

Sets the background vertical position offset for given bar metrics. This offset is used to adjust the vertical centering of bordered bar buttons within the bar.

Parameters:

  • adjustment (Float)

    The background vertical position offset for barMetrics.

  • barMetrics (UIBarMetrics)

    Bar metrics.

Returns:

- (Object) setTitlePositionAdjustment(adjustment, forBarMetrics:barMetrics)

Sets the title offset for given bar metrics. This offset is used to adjust the position of a title (if any) within a bordered bar button.

Parameters:

  • adjustment (UIOffset)

    The title offset for barMetrics.

  • barMetrics (UIBarMetrics)

    Bar metrics.

Returns:

- (UIOffset) titlePositionAdjustmentForBarMetrics(barMetrics)

Returns the title offset for given bar metrics. This offset is used to adjust the position of a title (if any) within a bordered bar button.

Parameters:

Returns:

  • (UIOffset)

    The title offset for barMetrics.