更改 UIActivityViewController 子视图背景颜色 SwiftUI
Change UIActivityViewController Subview Background colour SwiftUI
我正在尝试更改 UIActivityViewController 子视图背景颜色意味着当 UIActivityViewController 打开然后用户单击提醒时,提醒背景颜色会自动更改。我想根据主题设置相同。
代码:-
struct ShareSheet: UIViewControllerRepresentable {
typealias Callback = (_ activityType: UIActivity.ActivityType?, _ completed: Bool, _ returnedItems: [Any]?, _ error: Error?) -> Void
let activityItems: [Any]
var callback: Callback
let applicationActivities: [UIActivity]? = nil
let excludedActivityTypes: [UIActivity.ActivityType]? = [.addToReadingList]
func makeUIViewController(context: Context) -> UIActivityViewController {
let controller = UIActivityViewController(
activityItems: activityItems,
applicationActivities: applicationActivities)
controller.excludedActivityTypes = excludedActivityTypes
controller.completionWithItemsHandler = callback
controller.navigationController?.navigationBar.tintColor = .lightGray
controller.view.tintColor = .lightGray
controller.overrideUserInterfaceStyle = .light
return controller
}
func updateUIViewController(_ uiViewController: UIActivityViewController, context: Context) {
}
init(activityItems: [Any], callback: @escaping Callback = { activityType, completed, returnedItems, error in }) {
self.activityItems = activityItems
self.callback = callback
}
}
输出:-
第一屏:-
ScreenShot
第二屏:-
ScreenShot
第三屏:-
ScreenShot
预期输出:-
第一屏:-
Screen Shot
第二屏:-
Screen Shot
问:如何根据主题改变背景颜色?我试过上面的代码,但还没有结果。
有人可以向我解释一下如何获得进度吗?
如有任何帮助,我们将不胜感激。
提前致谢。
我在其他 class 中添加了 Tableview 背景。所以我需要在 Init 中更新 Tableview 单元格颜色。
代码:-
init(activityItems: [Any], callback: @escaping Callback = { activityType, completed, returnedItems, error in }) {
self.activityItems = activityItems
self.callback = callback
UITableView.appearance().backgroundColor = UIColor.systemGroupedBackground
UITableViewCell.appearance().backgroundColor = UIColor.systemGroupedBackground
}
我正在尝试更改 UIActivityViewController 子视图背景颜色意味着当 UIActivityViewController 打开然后用户单击提醒时,提醒背景颜色会自动更改。我想根据主题设置相同。
代码:-
struct ShareSheet: UIViewControllerRepresentable {
typealias Callback = (_ activityType: UIActivity.ActivityType?, _ completed: Bool, _ returnedItems: [Any]?, _ error: Error?) -> Void
let activityItems: [Any]
var callback: Callback
let applicationActivities: [UIActivity]? = nil
let excludedActivityTypes: [UIActivity.ActivityType]? = [.addToReadingList]
func makeUIViewController(context: Context) -> UIActivityViewController {
let controller = UIActivityViewController(
activityItems: activityItems,
applicationActivities: applicationActivities)
controller.excludedActivityTypes = excludedActivityTypes
controller.completionWithItemsHandler = callback
controller.navigationController?.navigationBar.tintColor = .lightGray
controller.view.tintColor = .lightGray
controller.overrideUserInterfaceStyle = .light
return controller
}
func updateUIViewController(_ uiViewController: UIActivityViewController, context: Context) {
}
init(activityItems: [Any], callback: @escaping Callback = { activityType, completed, returnedItems, error in }) {
self.activityItems = activityItems
self.callback = callback
}
}
输出:-
第一屏:-
ScreenShot
第二屏:-
ScreenShot
第三屏:-
ScreenShot
预期输出:-
第一屏:-
Screen Shot
第二屏:-
Screen Shot
问:如何根据主题改变背景颜色?我试过上面的代码,但还没有结果。
有人可以向我解释一下如何获得进度吗?
如有任何帮助,我们将不胜感激。
提前致谢。
我在其他 class 中添加了 Tableview 背景。所以我需要在 Init 中更新 Tableview 单元格颜色。
代码:-
init(activityItems: [Any], callback: @escaping Callback = { activityType, completed, returnedItems, error in }) {
self.activityItems = activityItems
self.callback = callback
UITableView.appearance().backgroundColor = UIColor.systemGroupedBackground
UITableViewCell.appearance().backgroundColor = UIColor.systemGroupedBackground
}