Change the tint color of the ActionSheet that appears when you long tap on a link in a WKWebView - swift

I'm writing an iOS 8 app and this problem is driving me crazy... I've set the tint color of my window in white (because I've got colored toolbar and navigation bar) but now, when in my WKWebView I long press on a Link, the actions titles of the Action Sheet that appears are written in White and so it's very difficult to read them.
Is there a way to change the tint color of this object?
I tried with
UIActionSheet.appearance.tintColor but it doesn't work, perhaps that control is not a UIActionSheet?
Thank you
Dave

I haven't found a solution but I've found a workaround: I set the tint color of the window as I like and then I set just the navigation bar's tint color and the toolbar's tint color in white.

This work for me, Swift 2.1 xCode 7 :
let actionSheet = UIActionSheet(title: "Launch your GPS navigator", delegate: self,
cancelButtonTitle: "Cancel", destructiveButtonTitle:
"Cancel", otherButtonTitles:"Open path in Google Maps"
, "Open path in Maps", "Open path in Waze")
if actionSheet.respondsToSelector("_alertController") {
let alertController = actionSheet.valueForKey("_alertController")
if ((alertController?.isKindOfClass(UIAlertController)) != nil) {
alertController?.view??.tintColor = UIColor.redColor
}
}
actionSheet.showInView(self.view)

Related

Background color of NSButton doesn't changes & option not present in XCode

Unlike my colleague, who has Bezel color option , I don't have it in my xcode
& when even when I try to use this SO approach by changing colors from creating a "Key Path", it doesn't change nor does it change with swift code in VC:
let button = NSButton()
button.layer?.backgroundColor = NSColor.red.cgColor

why toolbar text color always white in SwiftUI project

I have a problem in my SwiftUI project. In toolbar text buttons color is white, even I add this code
init() {
UIToolbar.appearance().barTintColor = UIColor.red
}
there is not any change, I do not know why? Any idea?
You could set an accent color to the view like this:
.accentColor(Color.red)

back button title color not changed while we open popover or present form controller in iOS 13

In iOS 13 back button title color not dimmed whenever we open popover or present other controller. Other part of application grayed out but not back button.
also tintColorDidChange function is not available for UIBarButtonItem so is there any way to do grayed out all back button titles.
Note: Back button image is being grayed.
Have you try by changing tint color of bar button?
I got same problem and solved by using
self.navigationController?.navigationBar.titleTextAttributes = [NSAttributedString.Key.foregroundColor: UIColor.clear]
self.navigationController?.navigationBar.tintColor = .red // put your desire color
self.navigationItem.backBarButtonItem = UIBarButtonItem(title: "", style: .plain, target: nil, action: nil)

UIAlertController does not turn all elements in the background to B/W

EDIT: Repository with my solution: UIAlertControllerDimmed
After showing UIAlertController, most of the background gets 'dimmed' and turns black and white. Some elements get darker, but don't turn B/W.
These elements are (from top to bottom on the screenshot):
UIImageView inside UINavigationItem
UIButton with red background color and white image
UIImageView inside UITabBarItem
I couldn't find anything related to this topic. What do I have to change to also get these items dimmed?
Here is the without the UIAlertController:
]
I think what's going on here is that you're setting the tintColor of some of the elements and you get different behavior for tintColor than you do for backgroundColor or textColor (or the colors in an image).
When an alert or action sheet appears, iOS 7 automatically dims the
tint color of the views behind it. To respond to this color change, a
custom view subclass that uses tintColor in its rendering should
override tintColorDidChange to refresh the rendering when appropriate.
For example, I created a simple app that displays an alert controller. I set the left button tint color to clear color and the text color to blue:
I set the right button tint color to system green color:
When I run the app and present the alert controller it looks like this
Before:
After:
In order to get the behavior you're looking for, you'll need to follow the advice in #Alexander's answer. You'll need to create grayscale versions of the four images on the screen and animate the transition to them.
You can have a helper function to animate the color change
fileprivate func dimElements(highlight: Bool) {
UIView.animate(withDuration: 0.3) {
self.sendButton.backgroundColor = highlight ? .red : .gray
}
}
and then call it when presenting/dismissing the alert.
let alert = UIAlertController(title: "Error", message: "Oops!", preferredStyle: .alert)
let okAction = UIAlertAction(title: "Ok", style: .cancel, handler: {_ in self.dimElements(highlight: true) })
alert.addAction(okAction)
self.dimElements(highlight: false)
present(alert, animated: true, completion: nil)
Thank you for your help.
In order to have a more flexible solution I decided to create a subclass of UIAlertController which captures a screenshot, turns it to grayscale colors and inserts it behind the UIAlertController when it gets presented. This way it works without having to do any additional work, and you don't need to implement fade animations for every single element that does not turn to grayscale colors by default.
Github repo: UIAlertControllerDimmed

iOS8 Swift TabBarController Change Icon Color

I'm trying to change the color of the icons in my TabBarController.
I've successfully changed the textcolor (just below the icons), but cant figure out how I change the icon color.
I've changed the icon-text-color like this:
UITabBarItem.appearance().setTitleTextAttributes([NSForegroundColorAttributeName: UIColor.orangeColor()], forState:.Selected)
UITabBarItem.appearance().setTitleTextAttributes([NSForegroundColorAttributeName: UIColor.whiteColor()], forState:.Normal)
I've put this into my AppDelegate.swift (didFinishLaunchingWithOptions).
Now the selected item-text is orange, and the unselected are white.
The icons however are still in blue / dark gray. How do I change these?
Unselected:
Selected:
being tBVC my tabBarViewController, I just do:
tBVC.tabBarItem.selectedImage = UIImage(named: "k-lenda(Hi)")?.imageWithRenderingMode(UIImageRenderingMode.AlwaysOriginal)
tBVC.tabBarItem.image = UIImage(named: "k-lenda(Lo)")?.imageWithRenderingMode(UIImageRenderingMode.AlwaysOriginal)
And in the attributes inspector I have the "Hi" image for the Bar Item.
I hope it helps !
Set tintColor property by UIAppearance.