I'm developing a little app and I would like to change the default global tint color from blue to orange. I've seen many ways to do it in Objective-C but I can't seem to get it to work using swift. How could I achieve this? Thanks in advance!
tintColor can be set for any individual view to color just one view, for the whole view in your view controller to color all its subviews, or even for the whole window in your application so that all views and subviews are tinted at once.
If you are setting the image for a button, just go to attributes inspector and change the button type to system. Then set the image and change the tint color. The color of the image will change.
The accent color is a broad theme color applied to views and controls. You can set it at the application level by specifying an accent color in your app's asset catalog. In macOS, SwiftUI applies customization of the accent color only if the user chooses Multicolor under General > Accent color in System Preferences.
A small update from Apple here. Tested with Xcode Version 12.4.
There is now an AccentColor
in the Color Asset catalogue which can be set in the build settings. In newer projects it is set by default but older projects might need to add it manually.
AccentColor
" (or whatever you like)
Global Accent Color Name
".
Note that
AccentColor
asset-name is NOT a preserved keyword, and can be anything custom, but the Build setting is what makes this work.Basically,
iOS
has nothing equal to theAndroid
theme yet (2021), where standard colors have keywords, and we can not simply set those in assets.
This answer was last revised for Swift 5.2 and iOS 13.5 SDK.
You can set the tintColor
on your window. Because tint color cascades down to all subviews (unless explicitly overridden), setting it on a window will effectively make it global inside that window.
Add the following line to your application(_:didFinishLaunchingWithOptions:)
or scene(_:willConnectTo:options:)
just before making the window key and visible:
window.tintColor = .systemOrange /* or .orange on iOS < 13 */
You can also set in in the storyboard by changing the Global Tint
property:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With