How to update default badge UI appearance in UITabbarController? - ios

As displayed above, default badge appears in red and white color. Can we change its color scheme and customize that view?
The only solution I found was, creating entire UITabbarController as custom control. Can't I use default control and only update badge or provide custom UI to badge?

You could just create view(UIButton for example.) with the color (or background image) and text you want and add that to the tabbar on the place you want. But I think that would be some kind dirty implementation... Coz, you need to calculate the frame according to how many UITabbarItems you have. Otherwise, custom tabbar controller is the way to go :) I don't think customization of the default badge is possible. Good Luck!

I couldn't find any way to create custom badge for UITabBarItem. The only way to achieve this is to use custom UIButton/UIViews.

Related

How to change UIPickerView's selected tint color in iOS 14?

One of iOS 14's changes included changing the UIPickerView to have a light gray selected row tint color. I was wondering if there is any way to change this or even access this property. I looked in the storyboard's attributes inspector and there didn't seem to be anything. Same with the code, autocomplete didn't bring up any selected tint related properties. Also looked around the internet but since it is a relatively new feature there wasn't anything helpful. Before iOS 14 I could put a UIView with my chosen color underneath to simulate this, but this update takes that away as the gray is still visible, and it looks bad. Here's a pic:
https://i.stack.imgur.com/BmoNO.png
I was wondering if there are any real ways to do this.
Also, a good solution would be to disable the light gray, because then I could use the strategy I show above. Any tips?
Without more information I can't say for sure, but in your View Controller class, access the UIPickerView and you can change it's tintColor and isOpaque properties. Something like this I would imagine.
pickerView.isOpaque = false
pickerView.tintColor = .clear
I looked into subviews. On delegate of a UIPickerView, within method didSelectRow I was able to set background.
pickerView.subviews.last?.backgroundColor = .clear

Swift UIButton - How to remove underline?

I have problem when in iOS settings is enabled this setting "Button Shapes"
It causing this underline in application (first picture with enabled setting, second without)
Any idea how to programatically or in storyboard disable it?
I tried attributed text but I get same result :(
I'm newbie in Swift.
Thanks for help!
It's not a problem. You should not make any attempt to counter any accessibility changes set by the user. They are there for a reason.
This is an answer by user4291543 from this question Remove underline on UIButton in iOS 7
[yourBtnHere setBackgroundImage:[[UIImage alloc] init] forState:UIControlStateNormal];
I found this answer works with SWFrameButton
And for all the others saying "Don't Do This", SWFrameButton is a very good example of when you would want to do this. I also think the OP's situation is a perfectly valid scenario as well...
I totally agree with #maddy's comment:
It's not a problem. You should not make any attempt to counter any accessibility changes set by the user. They are there for a reason.
But I did stumble on a way to accomplish the task at hand...
In addition to a UIButton, you'll also need to make a .png file that contains nothing (meaning the entire contents have an opacity of 0%). Go ahead and load that into your xcode project's assets.
Now go ahead and set the Button's Background to that image you just provided. (In my case, I called it clear) This will remove the underline from the button's text. However, now you can't see the boundaries of the button. This can be solved by changing the Background of the button's View. Go ahead and select any color for the View's Background property and now the background of the View visibly defines the button's boundaries. You're able to see this because your clear.png has an opacity of 0%.
see the Attributes inspector for UIButton here.
Rather than trying to defeat the underline by going to make a label perform some action via UITapGestureRecognizer, this allows you to still use a UIButton. Keeping inline with accessibility features to mark buttons for people that want to do that.
You could create a custom button class with a label (with clear color). If you set the text of this label instead it shouldn`t get an underline.
Are you sure you want to do that?
Apple added an accessibility feature to mark buttons for people that want to do that. Apple will probably reject your app because it defeats a system function meant to help the disabled.
I found the solution. All you have to do is set a picture as the background of the button. just pick a picture with the same color as the button you created.

iOS) How to add a divider(==separator) between tabbarItems

I searched this question many times but couldn't get enough information.
So I will use UIButton or UIView to replace UITabbar for customizing issue.
I want to put divider(separator) between two tabbarItems and bottom lines like the image below
But What I made now is below:
How can I make it as I want?
I did customize many view components(UIViewcontroller, UIButton, UITextfiled,UITableViewCell,UICollectionViewCell) but I don't know how to customize tabbarItem
I'm afraid there is no specific option to set a divider in UITabBar. But you can always use a custom tab bar. You can check this out, it has a special property for seperator image:
NMBottomTabBarController for iOS
There is also another option. You may like this :) I also used it myself in one of my app. I made an image that looks like a tab bar with seperator as a background image. Then put the items on it. Easy peasy. For example check this image:
Image Link
I hope this helps.

Change background theme using plist or other way which might change all theame at once

I want to know that is there any way which make change all xib's background at once.I want to make change all background of xib in one time when i change my theme name.
for example : If i choose "theam1" it make change at all view at once.Then if i change to "theme2" It make again change at all.
Like in android there is "style.xml" which make change at all in one time.May i get this type of functionality in xcode?
I know we can change it to set in viewwillappear at every time or set in appdelegate file but would i do via plist or other way which make change it all view in one time?
Please suggest me.
Thank you
It is relatively simple if all views has same background. Follow these steps on app delegate read the imagefilename from plist or any other way you want to use which theme. Then set image in mainwindow.xib file. and make all the views in whole app transparent by setting color as clearcolor. This way window's background will be visible behind all the view controllers's view. Hope this helps.
If you want more customization read values either from xml or plist and assign images according to view controllers in viewDidLoad method.

Customizing UITabbar idea ?

I read many posts on customizing color of selected tabbar item which is actually blue by default.
My idea was to put an UIImageView on each of my button.
Once the user select one button, I would then display the image (which is the same icon but with another colour as a gradient).
What do you think about that ?
Thanks in advance
You could always use this http://idevrecipes.com/2011/01/04/how-does-the-twitter-iphone-app-implement-a-custom-tab-bar/ and change it to include text and modify the colour.
Thankfully, iOS 5 introduced an appearance proxy allowing customisation of most basic UI elements, including the trusty UITabBar. The proxy is used to change ALL instances of a class throughout an application. However, with this came some basic properties available for specific instances.
See the selectedImageTintColor property of UITabBar for your needs.
Other appearance additions for this class are tintColor, backgroundImage and selectionIndicatorImage.

Resources