disable UINavigationBar gradient - iphone

Does anybody know how to disable gradient in UINavigationBar and make it totally black?

Create a class that descends from UINavigationBar and implements its own drawRect: method. You may have to draw the title and buttons yourself (in which case, why not just use a custom view?)

Related

iPhone: Drawing on a UIButton

This tutorial shows how to draw on a graphics context for the view using Quartz 2D:
http://www.techotopia.com/index.php/An_iPhone_Graphics_Drawing_Tutorial_using_Quartz_2D
But I want to draw on a UIButton, not on a view. How can I do that?
Thanks
Draw on UIView . Add the view as subview to your UIButton.
A button IS a UIView. It inherits from UIControl, which inherits from UIView.
So buttons have a drawRect method.
So you can do everything described in the article you linked on a button.
However, buttons are set up to do a lot of things for you, and overriding the drawRect method could make those things not work correctly.
Buttons normally draw a title and a rounded rectangle frame. You can turn that off by setting the button's type to custom.
Custom buttons will draw an image if you install one.
Buttons normally also either draw a highlight over their image, or have a second image to use for the highlighted state. If you want to implement drawRect, you'll need to handle drawing the highlighted state yourself.
In general, you want to avoid using drawRect and use some other technique to get the content you want into your views.
What, exactly, are you trying to do?

Add gradient to Back button of my UINavigationBar

I have subclassed UINavigationBar and overridden drawRect method so I can add a gradient to it. Now, I want to use the same gradient to the back button, but I don't know what is the easiest way (subclass UIButton, subclass UIBarButton item)
Thank you.
A lot of people on StackOverflow caution against subclassing UIButton.
create uibutton subclass
The easiest way to do what you want is to use [UIButton buttonWithType:UIButtonTypeCustom].
Make a transparent .png image of your button and set it as your button.image.
You can have a look here:
http://www.cimgf.com/2010/01/28/fun-with-uibuttons-and-core-animation-layers/
explore: http://idevrecipes.com/2011/01/12/how-do-iphone-apps-instagramreederdailybooth-implement-custom-navigationbar-with-variable-width-back-buttons/

Making a background of a UIViewController less "alpha"

I have an image that I want to use as the background of my UIViewController. I can add it as a UIView. The point is that I want to add some transparency to it. I don't want the image to be as opaque as the original image, because it has some graphics on it and would be way too distracting. So I want to make it faded, sort of. I hope that makes sense.
Maybe I should subclass UIView? Can anyone show me the code to do something like this?
you can set alpha of the uiview from the xib else you can use [self.view setAlpha:0.5]

Shadow inside UIView

I am working on iPhone application development and have come across shadows of UIView.
I know how to show shadows to a UIView but what I am actually interested in is to drop shadow inside the UIView.
Like when I set shadow properties of a UIView the shadow is dropped behind the view. I want it to come over the view so that the view looks as if it is pressed inside.
Example of such view is UITextField with roundedRect styling.
Thanks,
It depends a lot on the final effect you want to achieve.
The easies way would be a custom image with a prebacked shadow as background. This will give the illusion of a recession in the surface of the view. You can then add subviews to it as usual.
Alternatively, you can override the drawRect: method and draw the view as you like there, "inverted drop shadow" included.

How to change the background of a toolbar

How do I change the toolbar's background?
Why not just adjust the tintColor property? Or is changing the tint not good enough for your purposes?
There's one common technique, which is a giant hack, but it seems to work. Subclass UIToolbar and override -drawRect: and just have that draw whatever you want. You can then create instances of the subclass whenever you need a toolbar, and if you have a toolbar in a xib file then you can just select it and change the class to whatever your subclass is.