Saturday, November 30, 2013

How to implement custom code UINavigationBar

I ask you: How to code a custom UINavigationBar:


I intend to re-initialize inherited UINavigationController _navigationBar.


Seems syntax does not allow. Cheap does not pass.


Internet is not easy to find a few examples. Implementation are relatively simple, not my needs.




My needs:


title: is an image.


back button is a custom button (image)


forward button is also custom button


The background is completely transparent


I was a novice, heroes door gets advice. Has baidu and google a lot.


Some people say that with three20, so currently does not intend to engage in open. Always think ios development, this simple realization, there should be a simple way.


I did symbian android, to achieve this effect, very simple.

Reply:
You can consider the hidden system provides navigation bar, instead of using their own bar
Reply:
Customize a view to add controls
in view where you need
UIView * MyToolView = [[UIView alloc] initWithFrame: CGRectMake (0, 0, 320, 44)];
UIBarButtonItem * UIBarBtn = [[UIBarButtonItem alloc] initWithCustomView: MyToolView];
[Self.navigationItem setLeftBarButtonItem: UIBarBtn];
[UIBarBtn release];
[MyToolView release];


Reply:
My needs:
title: is an image.
back button is a custom button (image)
forward button is also custom button
The background is completely transparent
-------------------------------------------------- ----
Your these requirements can be achieved under UINavigationController not do
1.title: an image
You can use self.navigationItem.titleView = [[[UIImageView alloc] initWithImage: [UIImage imageNamed: @ ""]] autorelease];
2.back button is a custom button (image)
This can be set in the controller backBarButtonItem
parent controllerUIBarButtonItem * back = [[UIBarButtonItem alloc] initWithImage: [UIImage imageNamed: @ "x.png"]];
navController.navigationItem.BackBarButtonItem = back;
[Back release];
3 Set the background transparent
You can use the Category to expand UINavigationBar, such as:
@ Interface UINavigationBar (custom)

- (Void) drawRect {
self.alpha = 0.5f;

}
@ End

Rewritable drawRect method
Reply:
reference to the second floor of the reply:
customize a view to add controls
in the view where you need
UIView * MyToolView = [[UIView alloc] initWithFrame: CGRectMake (0, 0, 320, 44)];
UIBarButtonItem * UIBarBtn = [[UIBarButtonItem alloc] initWithCustomView: MyToolView];
......


mark next
Reply:
The reply was deleted at the moderator 2012-08-09 08:38:07

No comments:

Post a Comment