What UIKit Object controls “Look Up" popup appearance?
up vote
3
down vote
favorite
In our app, we have a light mode and a dark mode that switch the text colors and background colors. Theme
is an enum
with cases light
and dark
. We have methods for switching the colors, such as:
var textColor: UIColor {
switch self {
case .light:
return UIColor(red:60/255.0, green:60/255.0, blue:60/255.0, alpha: 1.0)
case .dark:
return UIColor(red: 240.0/255.0, green: 248.0/255.0, blue: 255.0/255.0, alpha: 1.0)
}
}
And we have an apply
method that applies the Theme to all of the views we use in our app:
func apply(){
defaults.set(rawValue, forKey: "selectedTheme")
UIApplication.shared.delegate?.window??.tintColor = tintColor
let navBarAppearance = UINavigationBar.appearance()
navBarAppearance.barStyle = barStyle
navBarAppearance.backgroundColor = backgroundColor
navBarAppearance.barTintColor = backgroundColor
navBarAppearance.tintColor = tintColor
navBarAppearance.isTranslucent = false
navBarAppearance.titleTextAttributes = [NSAttributedString.Key.foregroundColor: textColor]
let tabBarAppearance = UITabBar.appearance()
tabBarAppearance.barStyle = barStyle
tabBarAppearance.backgroundColor = backgroundColor
tabBarAppearance.barTintColor = backgroundColor
let toolBar = UIToolbar.appearance()
toolBar.backgroundColor = backgroundColor
toolBar.tintColor = backgroundColor
toolBar.barStyle = barStyle
toolBar.isTranslucent = false
toolBar.barTintColor = backgroundColor
UITableViewCell.appearance().backgroundColor = backgroundColor
UILabel.appearance(whenContainedInInstancesOf: [UITableViewCell.self]).textColor = textColor
UILabel.appearance().textColor = textColor
UITextField.appearance().keyboardAppearance = keyboardColor
UITextField.appearance().textColor = textColor
UITextField.appearance().backgroundColor = backgroundColor
UITextView.appearance().textColor = textColor
UITextView.appearance().backgroundColor = backgroundColor
MultiSelectSegmentedControl.appearance().tintColor = tintColor
MultiSelectSegmentedControl.appearance().backgroundColor = backgroundColor
UISegmentedControl.appearance().tintColor = tintColor
UISegmentedControl.appearance().backgroundColor = backgroundColor
UIButton.appearance().tintColor = tintColor
BigButton.appearance().backgroundColor = Theme.current.tintColor
BigButton.appearance().tintColor = Theme.current.backgroundColor
UIPickerView.appearance().backgroundColor = Theme.current.backgroundColor
UIPickerView.appearance().tintColor = Theme.current.tintColor
UITableView.appearance().backgroundColor = backgroundColor
UITableView.appearance().separatorColor = cellSelectionColor
UISearchBar.appearance().backgroundColor = backgroundColor
UISearchBar.appearance().barTintColor = tintColor
UISearchBar.appearance().searchBarStyle = .minimal
UITextView.appearance().backgroundColor = backgroundColor
UITextField.appearance(whenContainedInInstancesOf: [UISearchBar.self]).textColor = textColor
UISwitch.appearance().onTintColor = tintColor
let colorView = UIView()
colorView.backgroundColor = cellSelectionColor
UITableViewCell.appearance().selectedBackgroundView = colorView
}
When one selects text in our app and presses the "look up" button in the popup menu item, the popup that appears looks right. However, when you click on some of the views (such as dictionary and siri knowledge), the background or text colors appear to have been changed. Example:
How can we control the text color on this popup?
EDIT: The goal is to find the name of the UI Object that is created when the UIMenuItems are pressed. It’s not in the XCode Debugger Inspector, nor is it in self.view.subviews
. It seems to be some kind of built-in object that is hidden from the rest of the processes.
ios swift user-interface themes
add a comment |
up vote
3
down vote
favorite
In our app, we have a light mode and a dark mode that switch the text colors and background colors. Theme
is an enum
with cases light
and dark
. We have methods for switching the colors, such as:
var textColor: UIColor {
switch self {
case .light:
return UIColor(red:60/255.0, green:60/255.0, blue:60/255.0, alpha: 1.0)
case .dark:
return UIColor(red: 240.0/255.0, green: 248.0/255.0, blue: 255.0/255.0, alpha: 1.0)
}
}
And we have an apply
method that applies the Theme to all of the views we use in our app:
func apply(){
defaults.set(rawValue, forKey: "selectedTheme")
UIApplication.shared.delegate?.window??.tintColor = tintColor
let navBarAppearance = UINavigationBar.appearance()
navBarAppearance.barStyle = barStyle
navBarAppearance.backgroundColor = backgroundColor
navBarAppearance.barTintColor = backgroundColor
navBarAppearance.tintColor = tintColor
navBarAppearance.isTranslucent = false
navBarAppearance.titleTextAttributes = [NSAttributedString.Key.foregroundColor: textColor]
let tabBarAppearance = UITabBar.appearance()
tabBarAppearance.barStyle = barStyle
tabBarAppearance.backgroundColor = backgroundColor
tabBarAppearance.barTintColor = backgroundColor
let toolBar = UIToolbar.appearance()
toolBar.backgroundColor = backgroundColor
toolBar.tintColor = backgroundColor
toolBar.barStyle = barStyle
toolBar.isTranslucent = false
toolBar.barTintColor = backgroundColor
UITableViewCell.appearance().backgroundColor = backgroundColor
UILabel.appearance(whenContainedInInstancesOf: [UITableViewCell.self]).textColor = textColor
UILabel.appearance().textColor = textColor
UITextField.appearance().keyboardAppearance = keyboardColor
UITextField.appearance().textColor = textColor
UITextField.appearance().backgroundColor = backgroundColor
UITextView.appearance().textColor = textColor
UITextView.appearance().backgroundColor = backgroundColor
MultiSelectSegmentedControl.appearance().tintColor = tintColor
MultiSelectSegmentedControl.appearance().backgroundColor = backgroundColor
UISegmentedControl.appearance().tintColor = tintColor
UISegmentedControl.appearance().backgroundColor = backgroundColor
UIButton.appearance().tintColor = tintColor
BigButton.appearance().backgroundColor = Theme.current.tintColor
BigButton.appearance().tintColor = Theme.current.backgroundColor
UIPickerView.appearance().backgroundColor = Theme.current.backgroundColor
UIPickerView.appearance().tintColor = Theme.current.tintColor
UITableView.appearance().backgroundColor = backgroundColor
UITableView.appearance().separatorColor = cellSelectionColor
UISearchBar.appearance().backgroundColor = backgroundColor
UISearchBar.appearance().barTintColor = tintColor
UISearchBar.appearance().searchBarStyle = .minimal
UITextView.appearance().backgroundColor = backgroundColor
UITextField.appearance(whenContainedInInstancesOf: [UISearchBar.self]).textColor = textColor
UISwitch.appearance().onTintColor = tintColor
let colorView = UIView()
colorView.backgroundColor = cellSelectionColor
UITableViewCell.appearance().selectedBackgroundView = colorView
}
When one selects text in our app and presses the "look up" button in the popup menu item, the popup that appears looks right. However, when you click on some of the views (such as dictionary and siri knowledge), the background or text colors appear to have been changed. Example:
How can we control the text color on this popup?
EDIT: The goal is to find the name of the UI Object that is created when the UIMenuItems are pressed. It’s not in the XCode Debugger Inspector, nor is it in self.view.subviews
. It seems to be some kind of built-in object that is hidden from the rest of the processes.
ios swift user-interface themes
add a comment |
up vote
3
down vote
favorite
up vote
3
down vote
favorite
In our app, we have a light mode and a dark mode that switch the text colors and background colors. Theme
is an enum
with cases light
and dark
. We have methods for switching the colors, such as:
var textColor: UIColor {
switch self {
case .light:
return UIColor(red:60/255.0, green:60/255.0, blue:60/255.0, alpha: 1.0)
case .dark:
return UIColor(red: 240.0/255.0, green: 248.0/255.0, blue: 255.0/255.0, alpha: 1.0)
}
}
And we have an apply
method that applies the Theme to all of the views we use in our app:
func apply(){
defaults.set(rawValue, forKey: "selectedTheme")
UIApplication.shared.delegate?.window??.tintColor = tintColor
let navBarAppearance = UINavigationBar.appearance()
navBarAppearance.barStyle = barStyle
navBarAppearance.backgroundColor = backgroundColor
navBarAppearance.barTintColor = backgroundColor
navBarAppearance.tintColor = tintColor
navBarAppearance.isTranslucent = false
navBarAppearance.titleTextAttributes = [NSAttributedString.Key.foregroundColor: textColor]
let tabBarAppearance = UITabBar.appearance()
tabBarAppearance.barStyle = barStyle
tabBarAppearance.backgroundColor = backgroundColor
tabBarAppearance.barTintColor = backgroundColor
let toolBar = UIToolbar.appearance()
toolBar.backgroundColor = backgroundColor
toolBar.tintColor = backgroundColor
toolBar.barStyle = barStyle
toolBar.isTranslucent = false
toolBar.barTintColor = backgroundColor
UITableViewCell.appearance().backgroundColor = backgroundColor
UILabel.appearance(whenContainedInInstancesOf: [UITableViewCell.self]).textColor = textColor
UILabel.appearance().textColor = textColor
UITextField.appearance().keyboardAppearance = keyboardColor
UITextField.appearance().textColor = textColor
UITextField.appearance().backgroundColor = backgroundColor
UITextView.appearance().textColor = textColor
UITextView.appearance().backgroundColor = backgroundColor
MultiSelectSegmentedControl.appearance().tintColor = tintColor
MultiSelectSegmentedControl.appearance().backgroundColor = backgroundColor
UISegmentedControl.appearance().tintColor = tintColor
UISegmentedControl.appearance().backgroundColor = backgroundColor
UIButton.appearance().tintColor = tintColor
BigButton.appearance().backgroundColor = Theme.current.tintColor
BigButton.appearance().tintColor = Theme.current.backgroundColor
UIPickerView.appearance().backgroundColor = Theme.current.backgroundColor
UIPickerView.appearance().tintColor = Theme.current.tintColor
UITableView.appearance().backgroundColor = backgroundColor
UITableView.appearance().separatorColor = cellSelectionColor
UISearchBar.appearance().backgroundColor = backgroundColor
UISearchBar.appearance().barTintColor = tintColor
UISearchBar.appearance().searchBarStyle = .minimal
UITextView.appearance().backgroundColor = backgroundColor
UITextField.appearance(whenContainedInInstancesOf: [UISearchBar.self]).textColor = textColor
UISwitch.appearance().onTintColor = tintColor
let colorView = UIView()
colorView.backgroundColor = cellSelectionColor
UITableViewCell.appearance().selectedBackgroundView = colorView
}
When one selects text in our app and presses the "look up" button in the popup menu item, the popup that appears looks right. However, when you click on some of the views (such as dictionary and siri knowledge), the background or text colors appear to have been changed. Example:
How can we control the text color on this popup?
EDIT: The goal is to find the name of the UI Object that is created when the UIMenuItems are pressed. It’s not in the XCode Debugger Inspector, nor is it in self.view.subviews
. It seems to be some kind of built-in object that is hidden from the rest of the processes.
ios swift user-interface themes
In our app, we have a light mode and a dark mode that switch the text colors and background colors. Theme
is an enum
with cases light
and dark
. We have methods for switching the colors, such as:
var textColor: UIColor {
switch self {
case .light:
return UIColor(red:60/255.0, green:60/255.0, blue:60/255.0, alpha: 1.0)
case .dark:
return UIColor(red: 240.0/255.0, green: 248.0/255.0, blue: 255.0/255.0, alpha: 1.0)
}
}
And we have an apply
method that applies the Theme to all of the views we use in our app:
func apply(){
defaults.set(rawValue, forKey: "selectedTheme")
UIApplication.shared.delegate?.window??.tintColor = tintColor
let navBarAppearance = UINavigationBar.appearance()
navBarAppearance.barStyle = barStyle
navBarAppearance.backgroundColor = backgroundColor
navBarAppearance.barTintColor = backgroundColor
navBarAppearance.tintColor = tintColor
navBarAppearance.isTranslucent = false
navBarAppearance.titleTextAttributes = [NSAttributedString.Key.foregroundColor: textColor]
let tabBarAppearance = UITabBar.appearance()
tabBarAppearance.barStyle = barStyle
tabBarAppearance.backgroundColor = backgroundColor
tabBarAppearance.barTintColor = backgroundColor
let toolBar = UIToolbar.appearance()
toolBar.backgroundColor = backgroundColor
toolBar.tintColor = backgroundColor
toolBar.barStyle = barStyle
toolBar.isTranslucent = false
toolBar.barTintColor = backgroundColor
UITableViewCell.appearance().backgroundColor = backgroundColor
UILabel.appearance(whenContainedInInstancesOf: [UITableViewCell.self]).textColor = textColor
UILabel.appearance().textColor = textColor
UITextField.appearance().keyboardAppearance = keyboardColor
UITextField.appearance().textColor = textColor
UITextField.appearance().backgroundColor = backgroundColor
UITextView.appearance().textColor = textColor
UITextView.appearance().backgroundColor = backgroundColor
MultiSelectSegmentedControl.appearance().tintColor = tintColor
MultiSelectSegmentedControl.appearance().backgroundColor = backgroundColor
UISegmentedControl.appearance().tintColor = tintColor
UISegmentedControl.appearance().backgroundColor = backgroundColor
UIButton.appearance().tintColor = tintColor
BigButton.appearance().backgroundColor = Theme.current.tintColor
BigButton.appearance().tintColor = Theme.current.backgroundColor
UIPickerView.appearance().backgroundColor = Theme.current.backgroundColor
UIPickerView.appearance().tintColor = Theme.current.tintColor
UITableView.appearance().backgroundColor = backgroundColor
UITableView.appearance().separatorColor = cellSelectionColor
UISearchBar.appearance().backgroundColor = backgroundColor
UISearchBar.appearance().barTintColor = tintColor
UISearchBar.appearance().searchBarStyle = .minimal
UITextView.appearance().backgroundColor = backgroundColor
UITextField.appearance(whenContainedInInstancesOf: [UISearchBar.self]).textColor = textColor
UISwitch.appearance().onTintColor = tintColor
let colorView = UIView()
colorView.backgroundColor = cellSelectionColor
UITableViewCell.appearance().selectedBackgroundView = colorView
}
When one selects text in our app and presses the "look up" button in the popup menu item, the popup that appears looks right. However, when you click on some of the views (such as dictionary and siri knowledge), the background or text colors appear to have been changed. Example:
How can we control the text color on this popup?
EDIT: The goal is to find the name of the UI Object that is created when the UIMenuItems are pressed. It’s not in the XCode Debugger Inspector, nor is it in self.view.subviews
. It seems to be some kind of built-in object that is hidden from the rest of the processes.
ios swift user-interface themes
ios swift user-interface themes
edited Nov 15 at 3:08
asked Nov 11 at 17:20
rassar
2,2081928
2,2081928
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
up vote
1
down vote
accepted
There could be one or two possible issues
1)
You need to make sure that you are not setting textColor
for labels and backgroundColor
for the view
explicitly in the code. Label
's color
should be kept default
so that it can use the appearance
color
. For example, lets say we have set the textColor
as default as shown in the below image,
Now if we apply the textColor
appearance on UILabel
by doing UILabel.appearance().textColor = .green
. It will change the color
to green
once you will open the popup.
But if you are setting the textColor explicitly after setting the appearance as below,
UILabel.appearance().textColor = .green
copyrightLabel.textColor = .yellow
then it will discard the appearance
setting and set the color
(i.e, .yellow
) you provided later.
2)
The other possible issue could be the creation of this popup before changing the appearance. What i mean is if you have instantiated this popup at the time when appearance was light
so if you change the appearance now to dark
, it will not update the popup colors automatically to dark
because it's already created. If this is the case then you might have to do reloadData
on tableView/collectionView
and update all other view colors yourself.
1
Sorry for the late reply -- thank you so much, this worked great!
– rassar
Nov 19 at 2:49
@rassar Glad it helped!
– Kamran
Nov 19 at 5:44
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
1
down vote
accepted
There could be one or two possible issues
1)
You need to make sure that you are not setting textColor
for labels and backgroundColor
for the view
explicitly in the code. Label
's color
should be kept default
so that it can use the appearance
color
. For example, lets say we have set the textColor
as default as shown in the below image,
Now if we apply the textColor
appearance on UILabel
by doing UILabel.appearance().textColor = .green
. It will change the color
to green
once you will open the popup.
But if you are setting the textColor explicitly after setting the appearance as below,
UILabel.appearance().textColor = .green
copyrightLabel.textColor = .yellow
then it will discard the appearance
setting and set the color
(i.e, .yellow
) you provided later.
2)
The other possible issue could be the creation of this popup before changing the appearance. What i mean is if you have instantiated this popup at the time when appearance was light
so if you change the appearance now to dark
, it will not update the popup colors automatically to dark
because it's already created. If this is the case then you might have to do reloadData
on tableView/collectionView
and update all other view colors yourself.
1
Sorry for the late reply -- thank you so much, this worked great!
– rassar
Nov 19 at 2:49
@rassar Glad it helped!
– Kamran
Nov 19 at 5:44
add a comment |
up vote
1
down vote
accepted
There could be one or two possible issues
1)
You need to make sure that you are not setting textColor
for labels and backgroundColor
for the view
explicitly in the code. Label
's color
should be kept default
so that it can use the appearance
color
. For example, lets say we have set the textColor
as default as shown in the below image,
Now if we apply the textColor
appearance on UILabel
by doing UILabel.appearance().textColor = .green
. It will change the color
to green
once you will open the popup.
But if you are setting the textColor explicitly after setting the appearance as below,
UILabel.appearance().textColor = .green
copyrightLabel.textColor = .yellow
then it will discard the appearance
setting and set the color
(i.e, .yellow
) you provided later.
2)
The other possible issue could be the creation of this popup before changing the appearance. What i mean is if you have instantiated this popup at the time when appearance was light
so if you change the appearance now to dark
, it will not update the popup colors automatically to dark
because it's already created. If this is the case then you might have to do reloadData
on tableView/collectionView
and update all other view colors yourself.
1
Sorry for the late reply -- thank you so much, this worked great!
– rassar
Nov 19 at 2:49
@rassar Glad it helped!
– Kamran
Nov 19 at 5:44
add a comment |
up vote
1
down vote
accepted
up vote
1
down vote
accepted
There could be one or two possible issues
1)
You need to make sure that you are not setting textColor
for labels and backgroundColor
for the view
explicitly in the code. Label
's color
should be kept default
so that it can use the appearance
color
. For example, lets say we have set the textColor
as default as shown in the below image,
Now if we apply the textColor
appearance on UILabel
by doing UILabel.appearance().textColor = .green
. It will change the color
to green
once you will open the popup.
But if you are setting the textColor explicitly after setting the appearance as below,
UILabel.appearance().textColor = .green
copyrightLabel.textColor = .yellow
then it will discard the appearance
setting and set the color
(i.e, .yellow
) you provided later.
2)
The other possible issue could be the creation of this popup before changing the appearance. What i mean is if you have instantiated this popup at the time when appearance was light
so if you change the appearance now to dark
, it will not update the popup colors automatically to dark
because it's already created. If this is the case then you might have to do reloadData
on tableView/collectionView
and update all other view colors yourself.
There could be one or two possible issues
1)
You need to make sure that you are not setting textColor
for labels and backgroundColor
for the view
explicitly in the code. Label
's color
should be kept default
so that it can use the appearance
color
. For example, lets say we have set the textColor
as default as shown in the below image,
Now if we apply the textColor
appearance on UILabel
by doing UILabel.appearance().textColor = .green
. It will change the color
to green
once you will open the popup.
But if you are setting the textColor explicitly after setting the appearance as below,
UILabel.appearance().textColor = .green
copyrightLabel.textColor = .yellow
then it will discard the appearance
setting and set the color
(i.e, .yellow
) you provided later.
2)
The other possible issue could be the creation of this popup before changing the appearance. What i mean is if you have instantiated this popup at the time when appearance was light
so if you change the appearance now to dark
, it will not update the popup colors automatically to dark
because it's already created. If this is the case then you might have to do reloadData
on tableView/collectionView
and update all other view colors yourself.
edited Nov 15 at 3:51
answered Nov 14 at 12:29
Kamran
4,86711027
4,86711027
1
Sorry for the late reply -- thank you so much, this worked great!
– rassar
Nov 19 at 2:49
@rassar Glad it helped!
– Kamran
Nov 19 at 5:44
add a comment |
1
Sorry for the late reply -- thank you so much, this worked great!
– rassar
Nov 19 at 2:49
@rassar Glad it helped!
– Kamran
Nov 19 at 5:44
1
1
Sorry for the late reply -- thank you so much, this worked great!
– rassar
Nov 19 at 2:49
Sorry for the late reply -- thank you so much, this worked great!
– rassar
Nov 19 at 2:49
@rassar Glad it helped!
– Kamran
Nov 19 at 5:44
@rassar Glad it helped!
– Kamran
Nov 19 at 5:44
add a comment |
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53251249%2fwhat-uikit-object-controls-look-up-popup-appearance%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown