iOS Guides | Samples

MonoTouch.UIKit.UIToolbar Class

A UIView that displays a toolbar.

See Also: UIToolbar

Syntax

[MonoTouch.Foundation.Register("UIToolbar", true)]
[MonoTouch.ObjCRuntime.Unavailable(MonoTouch.ObjCRuntime.PlatformName.TvOS, MonoTouch.ObjCRuntime.PlatformArchitecture.All, null)]
public class UIToolbar : UIView, IUIBarPositioning, IDisposable

Remarks

To set UIBarButtonItem items in a UIToolbar, assign to the UIToolbar.Items property of the UIToolbar. To space items, use UIBarButtonItem.FlexibleSpace as shown in the following example:

C# Example

var tb = new UIToolbar(toolbarFrame);
var bbs = new UIBarButtonItem[] {
    new UIBarButtonItem(UIBarButtonSystemItem.FlexibleSpace),
    new UIBarButtonItem(UIBarButtonSystemItem.Action),
    new UIBarButtonItem(UIBarButtonSystemItem.FlexibleSpace),
    new UIBarButtonItem(UIBarButtonSystemItem.Add),
    new UIBarButtonItem(UIBarButtonSystemItem.FlexibleSpace),

    new UIBarButtonItem(UIBarButtonSystemItem.Bookmarks),
    new UIBarButtonItem(UIBarButtonSystemItem.FlexibleSpace)
};
tb.SetItems(bbs, false);

The previous code creates a toolbar that looks like this:

Related content

Requirements

Namespace: MonoTouch.UIKit
Assembly: monotouch (in monotouch.dll)
Assembly Versions: 0.0.0.0

The members of MonoTouch.UIKit.UIToolbar are listed below.

See Also: UIView

Public Constructors

Default constructor that initializes a new instance of this class with no parameters.
A constructor that initializes the object from the data stored in the unarchiver object.
Constructor to call on derived classes to skip initialization and merely allocate the object.
Initializes the UIToolbar with the specified frame.
A constructor used when creating managed representations of unmanaged objects; Called by the runtime.

Public Properties

[read-only]
static
AppearanceUIToolbar+UIToolbarAppearance. Strongly-typed property that returns the UIAppearance class for this class.
[read-only]
BarPositionUIBarPosition. Constant that identifies the position of a bar.
BarStyleUIBarStyle. The toolbar style.
BarTintColorUIColor. The tint color for this UIToolbar.
[read-only]
override
ClassHandleIntPtr. The handle for this class.
DelegateUIToolbarDelegate. An instance of the MonoTouch.UIKit.UIToolbarDelegate model class which acts as the class delegate.
ItemsUIBarButtonItem[]. A collection of UIBarButtonItem objects that make up the toolbar.
TranslucentBoolean. If true, then the toolbar is translucent.
WeakDelegateNSObject. An object that can respond to the delegate protocol for this type

Public Methods

static
AppearanceWhenContainedIn(params Type[]) : UIToolbar+UIToolbarAppearance
Returns a strongly typed UIAppearance for instances of this class when the view is hosted in the specified hierarchy.
static
GetAppearance(UITraitCollection) : UIToolbar+UIToolbarAppearance
Returns an appearance proxy for the specified traits.
static
GetAppearance(UITraitCollection, params Type[]) : UIToolbar+UIToolbarAppearance
Returns an appearance proxy for the specified traits.
static
GetAppearance<T>() : UIToolbar+UIToolbarAppearance
Obtains the appearance proxy UIToolbarAppearance for the subclass of UIToolbar.
static
GetAppearance<T>(UITraitCollection) : UIToolbar+UIToolbarAppearance
Obtains the appearance proxy UIToolbarAppearance for the subclass of UIToolbar.
static
GetAppearance<T>(UITraitCollection, params Type[]) : UIToolbar+UIToolbarAppearance
Obtains the appearance proxy UIToolbarAppearance for the subclass of UIToolbar that has the specified trait collection when the view is hosted in the specified hierarchy.
GetBackgroundImage(UIToolbarPosition, UIBarMetrics) : UIImage
This method will return the background image that is being used by the UIToolbar for the specified postion and orientation.
GetShadowImage(UIToolbarPosition) : UIImage
The image to be used for a shadow.
SetBackgroundImage(UIImage, UIToolbarPosition, UIBarMetrics)
Sets the image that will be displayed in the background of a toolbar for a given position of the toolbar.
SetItems(UIBarButtonItem[], Boolean)
Sets the UIBarButtonItem to be displayed in the toolbar, optionally animated the change.
SetShadowImage(UIImage, UIToolbarPosition)
Specifies the image to be used as a shadow for this UIToolbar.

Protected Methods

override
Dispose(Boolean)
Releases the resources used by the UIToolbar object.