When editing order, uitabbaritem icons do not appear on edit view - ios

In iOS 7, Apple has changed the background of the tabBar, edit screen (Where it says "Drag the icons to organize tabs.") to white.
Problem:
This causes a problem for me, in that my selected tabbaritem images are white, therefore you cannot see them on the edit view. It appears as if only the tabbaritems that are currently present (meaning, present in the tabbar) are editable (those icons do show up because they're red in their unselected state).
Questions:
Is there a way to change the background color of the edit view?
Is there a way to change the icon colors only in the edit view?

func tabBarController(tabBarController: UITabBarController,
willBeginCustomizingViewControllers viewControllers: [AnyObject]) {
var editView : UIView = tabBarController.view.subviews[1] as! UIView
editView.backgroundColor = UIColor.iStableDarkBlueTitleHeader()
}
override func viewDidLoad() {
super.viewDidLoad()
self.delegate = self
....

Related

set different color for navigation bar back button and back button text

I am trying to have different colors for back button text and back button.
If I set the global tint, it changes color for both. Is there a way I could have different color for both?
As i understand you just want to change back button color and back button in different screen different .Not globally So you can do this several way .Here is simplest way.
Just change navigation tint color of its viewDidLoad or viewWillApper method.
ViewController One :
override func viewDidLoad() {
super.viewDidLoad()
self.navigationController?.navigationBar.tintColor = UIColor.green
}
ViewConbtroller Two :
override func viewDidLoad() {
super.viewDidLoad()
self.navigationController?.navigationBar.tintColor = UIColor.red
}

How to change background color of text field when selecting another tab?

I have a Tab Controller with four tabs. On two of the tabs, I have text fields that have data validation. If the data validation fails, it changes the background color to red. However, when I switch to another tab and come back to the tab with data validation, the text field still has a red background. How can I change the background color of the text field after leaving the tab with data validation?
I have tried adding this to viewDidLoad()
self.textName.backgroundColor = UIColor.white
I have tried
func tabBarController(_ tabBarController: UITabBarController,
didSelect viewController: UIViewController) {
let tabBarIndex = tabBarController.selectedIndex
if tabBarIndex == 1 {
self.textName.backgroundColor = UIColor.white
}
}
Neither of these approaches work. Thanks!
You can try it inside viewWillAppear/viewDidAppear as viewDidLoad is called once when the VC is Loaded
self.textName.backgroundColor = UIColor.white
for didSelect , you need
self.tabBarController?.delegate = self

why UINavigationBar color change after return form aAnother viewController with diferente color

i have my base View controller with it´s embbed navigation controller so i set ist collor , when segue are executed the new view has it owns navigationbar color and it changes to it but after return to the back view this view takes the color from the previuos one.
i´m setting the color of the navigationbar like this
override func viewDidLoad() {
self.navigationController?.navigationBar.barTintColor = appDelegate.verde
}
its a defined color in the Appdelegate to be green color in the
in the next one i change in the color of the navigationbar the same way as above.
You change the color of the UINavigationBar and it remains changed unless you explicitly change it to something else. UINavigationBar does not depend on viewControllers - it's above them.
In order to have different color for each viewController when navigating between them back and forth, change UINavigationBar's color in viewWillAppear(_ animated: Bool).
override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)
self.navigationController?.navigationBar.barTintColor = appDelegate.verde
}
Instead of viewDidLoad you may put this code in viewWillAppear. This will be invoked each time the view is about to be presented so it will override any color changes for other views.

Customising the UITabBar.appearance in each View Controller [Swift]

I'm trying to set the tab bar to have a different background image on each view controller.
class CharacterVC: UIViewController {
var tabBarApparence = UITabBar.appearance()
override func viewDidLoad() {
super.viewDidLoad()
tabBarApparence.backgroundImage = UIImage(named: "BlueTB") //Loaded from Image Asset
}
This works fine and changes it to blue in that view, however when I go to the next view it stays the blue colour and doesn't change to the red colour which I programmed in with this code:
class AnonVC: UIViewController {
var tabBarApparence = UITabBar.appearance()
override func viewDidLoad() {
super.viewDidLoad()
tabBarApparence.backgroundImage = UIImage(named: "RedTabBar")
// addtional code here
}
I have an additional 2 view controllers, one should display the green version of the image and the other the purple version of the image.
Any suggestions which could fix this?
If you want to change appearance of TabBar in a view controller is very easy. You can this in function viewDidLoad or viewWillAppear. The code is the next:
// Set color of titles and icons in tabBar
self.tabBarController?.tabBar.tintColor = UIColor.redColor()
// Set color of background tabBar
self.tabBarController?.tabBar.barTintColor = UIColor.blueColor()
Replace code to viewWillAppear()
Better set backgroundImage to tabBar, not to UITabBar.appearance()

Custom UITabBarController with different item colours

What would be the correct approach to make a UITabBarController similar to this one from the Asana iOS App (button in the middle has a different colour than the others)?
Thanks.
To set the background color:
tabBar.barTintColor = UIColor.blueColor()
For the images, you can just set the image of your tab bar item.
In your Tab Bar Controller:
override func viewDidLoad() {
var tabBar = self.tabBar
var image = UIImage(named: "image")?.imageWithRenderingMode(.AlwaysOriginal)
tabBar.items![0].selectedImage = image
}

Resources