Custom UINavigationBar

30.08.2011. 11:24:38 sagatavoja deni2s

Background Image: sebastiancelis.com/2009/12/21/adding-background-image-uinavigationbar/

Custom Title: stackoverflow.com/questions/599405/iphone-navigation-bar-title-text-color


Custom Back button:

- (void)viewDidLoad
{
UIButton *button = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, 70, 30)];
[button addTarget:self action:@selector(back:) forControlEvents:UIControlEventTouchUpInside];

[button setImage:[UIImage imageNamed:@"close_button.png"] forState:UIControlStateNormal];
[button setImage:[UIImage imageNamed:@"close_button.png"] forState:UIControlStateHighlighted];
UIBarButtonItem *buttonItem = [[UIBarButtonItem alloc] initWithCustomView:button];

self.navigationItem.leftBarButtonItem = buttonItem;

[super viewDidLoad];
// Do any additional setup after loading the view from its nib.
}

- (void)back:(id)sender {
[self.navigationController popViewControllerAnimated:YES];
}

2 komentāri Komentēšana pieejama visiem.
deni2s komentēja 26.01.2012. 06:04:28
Komentāra reitings: 0

Kodā aizmirsts pievienot klāt

[button release];
[buttonItem release];

deni2s komentēja 26.01.2012. 12:43:01
Komentāra reitings: 0

//set custom navbar title http://stackoverflow.com/questions/599405/iphone-navigation-bar-title-text-color
- (void)setTitle:(NSString *)title
{
[super setTitle:title];
UILabel *titleView = (UILabel *)self.navigationItem.titleView;
if (!titleView) {
titleView = [[UILabel alloc] initWithFrame:CGRectZero];
titleView.backgroundColor = [UIColor clearColor];
if ([[[UIDevice currentDevice] systemVersion] floatValue] > 3.13)
{
titleView.font = [UIFont fontWithName:@"FS Me" size:13.5];
}
//NSLog(@"%@", titleView.font.fontName);
titleView.shadowColor = [UIColor darkGrayColor];
titleView.shadowOffset = CGSizeMake(0,-1);
titleView.textColor = [UIColor colorWithRed:255 green:255 blue:255 alpha:1.0]; // Change to desired color
self.navigationItem.titleView = titleView;
//[titleView release];
}
titleView.text = title;
[titleView sizeToFit];
}

Komentāra pievienošana

Ar * atzīmētie lauciņi ir jāaizpilda obligāti.





[ uz ziņu sarakstu ]

Reklāma
Par web.hc.lv

web.hc.lv ir vortāls, kurā tiek aplūkoti mājaslapu veidošanas un mārketinga aspekti, no idejas līdz gandarījumam.

[Valid RSS] Valid XHTML 1.0! Valid CSS!

RSS 2.0 ziņu barotne (news feed)  Twitter

reģistrēties