Thursday, May 30, 2013

UIButton UIButtonTypeInfoLight example in Objective C (iOS).

UIButton UIButtonTypeInfoLight

Specifies the style of a button.

typedef enum {
UIButtonTypeCustom = 0,
UIButtonTypeRoundedRect,
UIButtonTypeDetailDisclosure,
UIButtonTypeInfoLight,
UIButtonTypeInfoDark,
UIButtonTypeContactAdd,
} UIButtonType;

Constants
UIButtonTypeCustom
No button style.
UIButtonTypeRoundedRect
A rounded-rectangle style button.
UIButtonTypeDetailDisclosure
A detail disclosure button.
UIButtonTypeInfoLight
An information button that has a light background.
UIButtonTypeInfoDark
An information button that has a dark background.
UIButtonTypeContactAdd
A contact add button.

UIButton UIButtonTypeInfoLight example.
// Info button
UIButton* infoButton = [UIButton buttonWithType:UIButtonTypeInfoLight];
[infoButton addTarget:self action:@selector(showInfoView:) forControlEvents:UIControlEventTouchUpInside];
self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:infoButton];

Example of [UIButton UIButtonTypeInfoLight].
- (void) viewDidLoad {
  UIButton * info = [UIButton buttonWithType:UIButtonTypeInfoLight];
  // set your button's target and selector for whatever action here.
  self.navigationItem.rightBarButtonItem.customView = info;
}

UIButton UIButtonTypeInfoLight example.
UIButton* infoButton = [UIButton buttonWithType:UIButtonTypeInfoLight];
[infoButton addTarget:self action:@selector(infoButtonAction) forControlEvents:UIControlEventTouchUpInside];
UIBarButtonItem *modalButton = [[UIBarButtonItem alloc] initWithCustomView:infoButton];
[self.navigationItem setRightBarButtonItem:modalButton animated:YES];

End of UIButton UIButtonTypeInfoLight example article.