Created
July 23, 2012 05:50
-
-
Save yaakaito/3162142 to your computer and use it in GitHub Desktop.
CustomUIBarButton/なんかこんな感じにしてUIButtonのdrawRectでよしなに調整したらいけるんとちゃうか
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
UIBarButtonItem *item = nil; | |
UIImage *image = [UIImage imageNamed:@"navigation_bar_back_button"]; | |
UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom]; | |
[button setBackgroundImage:image forState:UIControlStateNormal]; | |
[button addTarget:self action:@selector(back) forControlEvents:UIControlEventTouchUpInside]; | |
[button setTitle:@"ほげ" forState:UIControlStateNormal]; | |
button.titleLabel.textColor = [UIColor whiteColor]; | |
button.titleLabel.textAlignment = UITextAlignmentCenter; | |
button.titleLabel.font = [UIFont boldSystemFontOfSize:12]; | |
button.frame = CGRectMake(0, 0, image.size.width, image.size.height); | |
item = [[UIBarButtonItem alloc] initWithCustomView:button]; | |
/* if ([[[UIDevice currentDevice] systemVersion] floatValue] > 4.9) { | |
UIButton *button = | |
item = [[UIBarButtonItem alloc] initWithTitle:@"ほ" | |
style:UIBarButtonItemStylePlain | |
target:self | |
action:@selector(toolBarButtonTapped:)]; | |
item.tintColor = [UIColor clearColor]; | |
[item setBackButtonBackgroundImage:image forState:UIControlStateNormal barMetrics:UIBarMetricsDefault]; | |
[item setBackButtonTitlePositionAdjustment:UIOffsetMake(-20, 0) forBarMetrics:UIBarMetricsDefault]; | |
[item setWidth:-100]; | |
} else { | |
UISegmentedControl *btn = [[[UISegmentedControl alloc] initWithItems:[NSArray arrayWithObjects:@"ほげ", 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]; | |
} | |
*/ | |
self.navigationItem.leftBarButtonItem = item; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment