Rounded UIBarButtonItems - iphone

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.

Related

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/

Remove shadow from UIBarButtonItem Image

Is there an easy way to remove the stupid image shadow from a uibarbuttonitem ?
Looks like the only way is to put an UIButton within an UIBarButton. So there is no way to directly remove the shadow from an uibarbutton image.

how to Change a Rounded Rect UIbutton background color

how to Change UIbutton background color??
I try it on IB, but it doesn't work. only changes it for custom button.
I would like to change the white color on the rounded rect button.
Or instead how to make a custom button whit rounded corners
thanks!
Rounded rect button's color can be changed to any color with the background color property in IB as well as through coding, but can not change its color to transparent color easily. For that, you better use a custom button with either rounded image or set layer as demonstrated in the example and don't forget to add Quartz Core framework in you project as well as to import it in your class.
UIBUtton *myBtn = [UIButton buttonWithType:UIbuttonTypeCustom];
myBtn.frame = frame; //your desired size
myBtn.clipsToBounds = YES;
myBtn.layer.cornerRadius = 5.0f;
[self.view addSubView:myBtn];
You may find it difficult to adjust the default button. However you can use any view you want with a custom button.
Here's an article on creating views with rounded corners:
http://iphonedevelopment.blogspot.com/2008/11/creating-transparent-uiviews-rounded.html
You also may look at a program called Opacity, which allows you to create a a lot of customized standard iOS interface art/buttons.
http://likethought.com/opacity/
UIButton *tagButton = [UIButton buttonWithType:UIButtonTypeRoundedRect];
and have a look at this... that my do the trick.. i did it for mine.
You can use a custom UIButton with custom images for backgroundimage for each state. Just make the different states of your rounded button in photoshop for example.
You can use Custom button But for that use the image of button of white rounded corners
so it will be look like white round rectangle button
You should use UIButtonTypeCustom, instead of any other.

uiimageview or uibutton not square

Is there anyway to make an uiimageview or uibutton that is not squared?
I'd need several images that can be clickable but dont have a squared shape.
Is there anyway to solve this?
Check out this thread,
Simple way of using irregular shaped buttons
Hope this will solve your problem
Use a custom button to get a different shape on the button.
A usefull link (though for xcode 3) is here: http://howtomakeiphoneapps.com/2009/09/how-to-create-custom-buttons-in-interface-builder/
For UIImageView it shouldn't matter much.. Any part of the UIImageView that doesn't get filled by the picture, stays transparant if I'm not mistaken.
you can create a button and set its image or background image as required
good luck

UITextView - how to make it look like in the IB?

I am initializing a text view from my code, not from the interface builder and it appears to be just a white rectangle. I want it to have the same rounded shape as is in the interface builder. How can I achieve this?
The same question concerning UITextView.
Thanks.
The text view is rectangular even in IB. A UITextField has rounded corners. For that, just set the borderStyle property of UITextField to UITextBorderStyleRoundedRect
You maybe confusing UITextView with UITextField.
UITextField has a optional rounded rectangle border. UITextView is just the text, no border. You have to bring your own border to the party and place it behind the UITextView.