Add gradient to Back button of my UINavigationBar - iphone

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/

Related

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]

Rounded UIBarButtonItems

I need to make UIBarButtonItem rounded. In xib even though the style attibute specified as bordered it displays a rectangular shape. Is there any work around to achieve this?
Regards,
Dilshan
Try to use initWithCustomView:(UIView *)customView where the customView is a custom UIButton with a round image.

Press a button behind a UIView

I have a button and half of the button is covered by a UIView (for styling).
I was wondering if there was any way to make this UIView "touch transparent" as it were, so if you press on it it lets you select the image behind it?
Or will I just have to make it a button itself?
Thanks
Tom
You should set the UIView's userInteractionEnabled property to NO.
try to make the UIView opaque to NO

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.

disable UINavigationBar gradient

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?)