Tint UIBarButtonItems in inputAssistantItem on iPad - ios

I have a couple of UIBarButtonItems used to apply formatting to text in a UITextView. On iPhone, these buttons are added to a UIToolbar that's set as the inputAcessoryView for the textview. On iPad, the buttons are added to the textview's inputAssistantItem toolbar instead.
The states of the buttons are toggled on or off by changing the tintColor of the UIBarButtonItems (i.e. when the currently selected NSRange should be bold the tintColor of the bold button is changed to indicate that it is active).
This works great when the UIBarButtonItems are added to a UIToolbar on iPhone, but I can't get this to work for the inputAssistantItem on iPad. When I change the tintColor of a button, nothing changes.

For anyone interested, I managed to fix this by adding a UIButton to to each UIBarButtonItem and then changing the tintColor of the button instead of the UIBarButtonItem.

Related

Standard UIButton blink animation not working on IOS 8 only if title is only set programatically

I have a UIButton of type:System and title:Plain added to my view with IB.
The title of the UIButton is blank in IB.
The title is set programmatically with [.button setTitle:NSLocalizedString(#"title", #"") forState:UIControlStateNormal];
On IOS 9 the button has the standard blink animation when tapped.
On IOS 8 the button doesn't have the standard blink animation when tapped.
If I set a title for the button's default state in IB then the standard blink animation starts working on IOS 8.
The trouble is I have a lot of buttons like this and adding garbage titles for all of them in IB will be confusing for translators.
Is there another way to fix this for IOS 8?

Change UIWebView Done button color

I am using a UIWebView to display content in an app and would like to change the color of the Done button that is displayed whenever a select control is used.
It is currently displaying as white on gray which is hard to see.
The "Done" button is white because you are probably setting the tintColor to white for all UIBarButtonItems using UIAppearance. That affects the "Done" Button in the picker view which also happens to be a UIBarButtonItem.
So you have to exclude the "Done" button in the picker view from the global white tintColor. I don't know if you only need the white UIBarButtonItems in your navigation bar, but if you do you could do this to only set the tintColor for the bar button items in your navigation bar and leave all other UIBarButtonItems untouched:
UIBarButtonItem.appearanceWhenContainedInInstancesOfClasses([UINavigationBar.self]).tintColor = UIColor.whiteColor()
However this is only available in iOS9 and the old appearanceWhenContainedIn method that works for older iOS versions is not available in Swift.
So, if you are working with Swift and you have to target earlier iOS versions than iOS9 this is probably not working for you. In that case you have to remove the UIAppearance setting for the white tintColor and set the tintColor for the UIBarButtonItems in your navigation bar "manually" without using UIAppearance.
Another possible solution is to just do
UIPickerView.appearance().tintColor = UIColor.blueColor()
put this in your AppDelegate and you are ready to go!

UIStepper tintColor not functioning?

I recently updated my project to iOS 7.1. During the switch, nothing changed except for one thing. In iOS 7, within my app delegate, I set my window tint color to blue. On a view controller, I have a UIStepper that I set the tint color as white in both Interface Builder and programmatically. Prior to updating, the stepper was tinted white while everything else was blue as it should have been. After being updated, however, the stepper remains the tint color of my app. Does anybody know why this happens, or how to fix it? Any insight is appreciated. Thank you.
I solved the problem by clicking on my UIStepper in Interface Builder, clicking on the first pane of the item inspector, and changing global tint to white.

Button Hiding the text in iOS6

I have a text box which has a popover. Also placed a button on top of the text box to make it clickable so that when button is clicked the popover is opened and any item selected will be shown in the text box. This is working fine in iOS7 but in iOS 6 i am able to select the item in popover but the button is hiding the text. Tried setting colour of button but didn't work.
Please help.
If you set the type of the button to "Custom", and you don't set an Image or a Background Image, the button will be invisible on versions prior to iOS7 too.
If you create the button programmatically:
UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];
If you change it on your interface:
Instead of using button, you can open popover by UITextbox itself. Just place the button's IBAction code in textbox's IBAction with EditDidBegin Event.
Set UIbutton's buttontyoe to UIButtonTypeCustom for iOS 6

uitoolbar with icons/text similar to uitabbar

Ideally I want to use a UIToolbar but I want the icons at the bottom to appear as they would in a UITabBar meaning with icon for default and highlighted states and title beneath. I know I can drag a UIButton onto the toolbar and it will create a UIButton inside of a UIBarButtonItem, but I can't seem to manipulate the UIButton to show a title beneath? The other problem I'm having is when I set the alignment of the button in IB (in the Control section) it only changes the alignment for the default state not the highlighted state. Can anyone give me some pointers here that would be great thanks!
rc
Putting the UIButton inside a UIBarButtonItem is the best way I've found to do it. Just set the text for the button and it should show up fine. When manipulating the positioning, remember you're manipulating the position of the UIBarButtonItem and not the UIButton. Hope that helps!

Resources