Changing UIAlertController's tint color globally? - swift

I am trying to change all my UIAlertController's tintColor to a custom color because there are lots of these in my app and I want to go shortcut. After a little research on the internet I found this snippet and it seemed working at first.
UIView.appearance(whenContainedInInstancesOf: [UIAlertController.self]).tintColor = UIColor.red
Later, I realized a bug -or anything else, I don't know yet- that this snippet has effect on UIToolbarButton's tintColor. It has been set to a custom color on the storyboard and I tried to set programmatically in related viewDidLoad but it does not work. The color of the text is default blue. Moreover, I also tried to set UIView.apperance.tintColor directly it worked on that button but, for that situtation the items that should have meant to be white turned to that custom color. As you can understand I don't want that.
If someone helps, i will be appreciated because he will save me from all crtl+c and ctrl+v process:) Have a good day!

Related

Change the color of a focused element (Picker) SwiftUI - WatchOS

How can I change the focus color of a selected element in WatchOS7 with swiftUI. Here's my example below with a Picker whose focus color is green (the default one) but I want to change it to blue to be consistant with my app layout.
I search over the internet and stackoverflow but did not find andy solution to this. Is it possible to do it in SwiftUI.
That's the focus color and you cannot change it. At least no with standard view modifiers like .accentColor, .tint, etc.
You can try to hide it by overlying another view (like in this response), for example, or try to reach to UIKit using instrospection.
Probably it's best to be at peace with the fact that it's system behavior.
Maybe you should try using .accentColor modifier to the picker.

UILabel automatically changes color

i'm facing a really strange problem: i have some UILabel in my view, which has a black background, so i set their text color to white in Interface Builder in order to see them, the problem is, when i run the app on the simulator or on my iphone with ios7 or iOS 6.1.3 i can update them without problems (for update i mean: myLabel.text = #"Something")
but when i run the app on my sister's iphone 3gs with iOS 6.0 at the moment i update them the font color turns black. It seems that on her phone the label can't remember the color set on IB.
Does anyone of you know why this happens?
Thanks
It sounds like you have set the label "type" to "Attributed" in Interface Builder.
If this is the case then it is not the label that holds the text colour. It is the text itself.
If you replace the text with something else then the default text color of black will be used.
If you want to continue using Attributed text then you need to add a "foregroundColor" attribute to the text before setting it to the label.
The easier way round this is to change the label type to "Plain" in Interface Builder.
Of course, this depends on you having set it to Attributed.
I think you shouldn't use default label color in the interface builder, just provide something else (black color or etc.).
I ran into a similar problem. Was stumping me completely, until I quit and relaunched the simulator. It wasn't enough to just close the window or rebuild. I had to cmd-q, then build and launch again. Magically fixed the issue. Annoying.. but worked for me

How can I change UIActionsheet button colors?

I want to change background colors of UIActionSheet buttons.How can I do that ?
There is no way to change UIActionSheet button colors, apart from adding a destructive button that creates a red option. If you really want custom button colors, try making a custom UIActionSheet like so: custom-uiactionsheet-using-core-animation
I had the same issue and only clicked together a basic solution.
The core animation approach is superior but that may be simpler
https://github.com/Daij-Djan/DDUtils/tree/master/ui/M42ActionSheet%20%5Bios%5D
Disclaimer: mine ;) and also not the coolest code since its from 2010 but it should work fine

Change the color of the iPhone keyboard (working with Phonegap/Cordova)

As the title states: is it possible to change the keyboard color to black (some call it transparent?) when working with Phonegap/Cordova? I've googled a lot but I can't seem to find anything about it. So can it be done? Either with HTML5/jquery or in XCode?
A picture of what I'm looking for:
To use a dark theme on the iOS Keyboard, you can follow this article.
You can add the Objective-C code to your PhoneGap project's AppDelegate.m

Applying color to uilabel in interface builder goes to background?

I've succesfully changed the font (color,size,type) of a text label (UILabel) on my app. Then I tried to do the same on 2 other labels. But this time the color goes to the background. After looking for what could be the issue I still dont understand. Can you help me ?
Thx for your help,
Stephane
Interface builder just does that sometimes. It's a glitch. Just change the background back to what you want.