I have a UIToolbar where all the buttons have a style of UIBarButtonItemStylePlain. One of these buttons toggles a setting in my app and I would like to have some type of Selected state when that feature is enabled.
Since I am not using bordered buttons, setting the style to UIBarButtonItemStyleDone would not work because the button would not match. Is there an easy way to change to color of the icon on the button?
For a sample, look at the location button in the Maps app on the iPad. It does exactly what I am looking for.
Sure thing. You can set the background image with initWithImage:style:target:action: or supply a custom view with initWithCustomView:
Related
I would like to set navBar buttons like safari as following image shows. However I can only set a custom image for toolbar button but square button container remains although I set plain style. How to reach it? Thank you
Plain is only for tool bars not nav bars, that's the only way you can achieve no border. You must use a custom UIButton on your navbar to achieve the same results.
If you need an icon somewhat like that, you can check on Default Icon
Use UIBarButtonItem method for creating bar button
- (id)initWithCustomView:(UIView *)customView;
and create custom view with UIButton of type UIButtonTypeCustom
On a number of iPhone applications I'm seeing a little blue circular button that, when clicked on, displays information about the application. Is this something that is built into the iOS SDK, or is it simply a custom button with a custom image?
You can make an info button in Interface Builder by placing a button (a Rounded Button) and changing its type into dark or light info button.
You can also crate an info button programmatically like this:
UIButton *infoButton = [UIButton buttonWithType:UIButtonTypeInfoDark];
It's in the Interface Builder. Place a Round-Rect button and change the type to "Info Light" or "Info Dark"
Then you simply link it to creating a new subview in which you place all the information about the app or whatever else you would like to put there.
Yes, it is built into the SDK.
Place a button in interface builder and choose info dark and info
light from the button types in the attributes inspector.
Is this the button?
It is available in dark gray and light gray only.. if it is not.. Please post a link to which button you are referring to.
You can make an info button in Interface Builder by placing a button (a Rounded Button) and changing its type into dark or light info button.
I am creating a custom tab bar for my iPhone app and I need to change the images. I have changed the actual tab bar background, but I need to know how to add custom images for the icons and their respective "selected" icons. I also need to remove the square highlight that is default. Pretty much, it just needs to be my icons. Also wondering if the images can be coloured or not. I've looked a lot of this, but no one seems to have the solution.
Someone please help.
hide the inbuilt tabBar view
create your own custom UIView (or UIScrollView in case if you need more number of tabs) with the frame of inbuilt tabBar view and fill up, especially with array of UIButtons & then add your custom view as a subview of the TabBarController.
Play with the UIButton's background image (which is your tab icon image) and its addTarget:action:forControlEvents: in order to set the appropriate selectedIndex value of the TabBarController, i.e. set the selectedIndex according to the button's position in the custom view.
This is how I've implemented :)
No. You cannot customise the tab bar icons in the UITabBar.
They are designed to be used with an alpha masked image.
Someone discovered a way to hack the colours though here: Custom colors in UITabBar
how can i just change the color,of a button when i set the focus on the button in iphone.
I mean to say , for example we have 5 buttons, and i am just setting the focus on each of the button. i want those buttons to be higlighted with different color.
but when press or touch up inside the utton, the navigation is made to the respective forms, that is set for that button.
you can write method, for example, let it be
- (void) changeButtonState:(UIButton*) buttonToChange;
then you can call it in your onBtnClk method for button you need. in that method you can change image for your button's UIControlStateNormal mode. and if I understand right, you can use toolbar or tabbar instead of buttons.
Guess you have already asked this issue differently here..
But have you checked the answer?? You can use any of those methods at your will!
The default color when a button is pressed on Iphone is blue. How can I change to some other color?
The same applies to the case when I select a row of UITableViewCell. How can I change the color when selected?
Thanks.
In the case of the UIButton, I think you need to provide your own images for the highlighted state. Many of the controls in the iPhone OS like the UIToolbar and UINavigationBar provide a "tint color" that you can change to customize their appearance. The UIButton has a couple of predefined appearances, like "Rounded Button", but most of the time I end up using custom images for mine.
I'm not sure about the UITableViewCell - you might need to subclass it and draw the selected state yourself. There may be a "background image for state" that you could change instead, though.
Sorry that's really not the best news. Maybe someone else knows a better way?