UIButtonTypeInfoLight masquerading as a UIBarButtonItem
Just in case you were wondering how to use a UIButtonTypeInfoLight (or UIButtonTypeInfoDark) as a UINavigationItem (a la UIBarButtonItem), here is what I threw together. Put this code in your view controller’s viewDidLoad method:
UIButton *button1 = [UIButton buttonWithType:UIButtonTypeInfoLight]; button1.frame = CGRectMake(0.0f, 0.0f, 40.0f, 32.0f); [button1 addTarget:self action:@selector(aboutButtonPressed:) forControlEvents:UIControlEventTouchUpInside]; UIBarButtonItem *aboutButton = [[UIBarButtonItem alloc] initWithCustomView:button1]; self.navigationItem.leftBarButtonItem = aboutButton; [aboutButton release]; |
Adjust the frame to your taste, and supply the aboutButtonPressed method with an (id)sender parameter, and you are good to go.