I want to add customized arrow buttons to UINavigation Bar which comes at the top.
what I want to do is create a custom image button and place it over the bar. When I t
Try doing the following:
UINavigationBar *bar = self.navigationController.navigationBar;
bar.titleView = leftArrowButton; // change title view
bar.leftBarButtonItem = leftArrowButton; // if ref is UIBarButtonItem
You should consider using a UIBarButtonItem
rather than UIButton
.
You can also customize the bar buttons as well with images (using the initWithImage:style:target:action:):
UIBarButtonItem *item = [[UIBarButtonItem alloc] initWithImage:myImage
style:UIBarButtonItemStyleBordered
target:self action:@selector(buttonPressed:)];
bar.leftBarButtonItem = item;
[item release];
You can also use any view you like (with some consideration for the size) using the initWithCustomView::
UIBarButtonItem *item = [[UIBarButtonItem alloc]
initWithCustomView:leftArrowButton];
bar.leftBarButtonItem = item;
[item release];