Created
February 13, 2012 01:46
-
-
Save tikitikipoo/1812562 to your computer and use it in GitHub Desktop.
UIBarButtonItemのtintColorはios5からなのでios4でも同様なことができるように
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 出所:http://wizard.st/blog/archives/156 | |
// :http://fredandrandall.com/blog/2011/03/31/how-to-change-the-color-of-a-uibarbuttonitem/ | |
UIBarButtonItem *item = nil; | |
if ([[[UIDevice currentDevice] systemVersion] floatValue] > 4.9) { | |
item = [[UIBarButtonItem alloc] initWithTitle:title | |
style:useStyle | |
target:self | |
action:@selector(toolBarButtonTapped:)]; | |
[item setTintColor:[UIColor blackColor]]; | |
} else { | |
UISegmentedControl *btn = [[[UISegmentedControl alloc] initWithItems:[NSArray arrayWithObjects:title, nil]] autorelease]; | |
btn.momentary = YES; | |
btn.segmentedControlStyle = UISegmentedControlStyleBar; | |
btn.tintColor = [UIColor blackColor]; | |
[btn addTarget:self action:@selector(toolBarButtonTapped:) forControlEvents:UIControlEventValueChanged]; | |
item = [[UIBarButtonItem alloc] initWithCustomView:btn]; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment