I have a UIToolbar where I have dragged a UIButton. When I set the button properties to Custom, and assign an image (or background image) the graphics don't appear. However, when I give it a custom text, the text will appear. Why is it that the images don't appear?
Are you sure the image is present in your bundle/project?
Are you setting the button's image for UIControlStateNormal?
Related
I have a button.I have added an image to its image property and also to its background image property.Now it only display the button with added images and can't see button text.What is the reason.
Thanks for the help.
Setting the background image is fine but when you set the button.image property, it is overlaid over the textfield that the button has so you do not want to add an image to that property if you plan on using the buttons text.
you have to play with the EdgeInset property of the UIButton to properly align the content of the button (title an image)
use setBackgroundImage:forState: method of UIButton
You have to add image to background if you want to add title later or else use image with text.
Put image in background image just below image if you do it through nib
I am trying to add an image for my UIBarButtonItem from the xib file itself. However, I am getting a grey coloured button which is of the same size and shape as that of my image. How can I display the image correctly and directly from my xib file itself without going into the writing of code manually ?? The button is present on a toolbar. Thanks and Regards.
Use UIButton beside of barButtonItem. It will automatically make a barButton and a Button inside of that.
then you need to change batButtonItem text to "" and change the Image of UIButton
as I tested it will work and show your pic beside of barButtonItem
Can I add an icon to the uisearch bar like this
Ya you can add the icon if you are talking about the image on left then just add a image and if you are talking about the image to the right. which i think is a search button then you can add a button and do your search code on it.
ok so what you have to do now is, i am assuming that you want to implement the search bar with icon on the toolbar. just add a UIButton and in the IB select the UIButton and go to attribute inspector and set the type to custom.
Now when you add the image to it(set the background property to the image you have selected)
By doing this you can easily resize your image.(means just resize the button, it will automatically resize your image too).
hope this will work.
How to change color of leftBarButtonItem of UIBarButtonItem in NavigationBar?
if I am trying to set image in bar button through interfaceBuilder it shows border on image in bar button so is there any specific size for image for bar button or how to set image with-out showing border in it ?
If I am adding BarButton dynamically it doesn"t appear while running App
and if I am adding leftbarButton in xib only and connecting outlets then the leftbar button become visible but I am not able to assign customview view to it my ultimate goal is to change the color of left bar buttton
Please Help and Suggest,
Thanks
Create the bar buttom item with a custom view using -[UIBarButtonItem initWithCustomView:]. That way, you have all the control you want over the appearance.
I think you can use:
- (id)initWithImage:(UIImage *)image style:(UIBarButtonItemStyle)style target:(id)target action:(SEL)action
You can set custom image for your bar button.
If it's just the colour you want to change, add the button to the bar and then set the tint colour of the bar (see docs on UINavigationBar or UIToolBar). This of course changes the bar colour as well as the button however, but it's good practice (UI consistency wise) to use the same colour for UIBarButtonItems and their bars especially if you're using out-of-the-box buttons.
i have a image ,i want to launch url when i press that logo or image ,how to implement ib action for that image view ...
can any one give suggestion i selected image view in ib to place my logo is it right?
UIImageView is not a subclass of UIControl so it doesn't support the target-action mechanism. You have 2 options:
Use a UIButton instead (and set your image as the button's background image).
Set userInteractionEnabled = YES; on your image view and implement the touch handling in -touchesMoved:` etc. yourself.