RMDateSelectionViewController
RMDateSelectionViewController copied to clipboard
Date Selector Doesn't handle iOS 13 dark mode
Hello friend!
We've noticed that on iOS 13 with Dark Mode enabled, the selector is invisible:
I've gotten this to work for me by adding a:
if #available(iOS 13.0, *) {
actionController.overrideUserInterfaceStyle = .light
}
Right before presenting calendar selector!
I also notice that I can't seem to set the style to anything dark, I was going to add a
if #available(iOS 13.0, *) {
puts("!: we are 13")
if self.webViewController?.traitCollection.userInterfaceStyle == .dark {
puts("!: We are dark")
style = RMActionControllerStyle.black
}
}
// then initialize the actionController
let actionController: RMDateSelectionViewController = RMDateSelectionViewController(style: style)!
However, even hardcoding it to .black
seems to make keep it white!
Hi there!
The current master branch contains new styles for RMDateSelectionController, which automatically adapt to the current environment.
In addition, the master branch contains some bugfixes which are not yet available in the latest release.
Can you give the master branch a try to see if it improves the situation for you?
Best regards, Roland
Hey Roland!
I tried both master and this commit directly https://github.com/CooperRS/RMDateSelectionViewController/commit/7d3d785221447e3e14277cad0fc1e4e00aaa5fd7, but didn't seem like in either way I was able to theme it black or have have the text show up in Dark mode.
var data = message.body as! Dictionary<String, AnyObject>
let date: Date
if let year = data["year"], let month = data["month"], let day = data["day"] {
let dateFormatter = DateFormatter()
dateFormatter.dateFormat = "yyyy,MM,dd"
// Need to add 1 to month, since iOS wants months to start at 1 instead of 0
date = dateFormatter.date(from: "\(year),\((month as! UInt) + 1),\(day)") ?? Date()
} else {
// Fallback to today's date
date = Date()
}
let selectAction = RMAction<UIDatePicker>(title: "Set Date", style: RMActionStyle.done) { controller in
self.setDate(controller.contentView.date)
}
let cancelAction = RMAction(title: "Cancel", style: RMActionStyle.cancel) { _ in
print("Date cancelled")
self.webViewController?.queueDispatchableAction(DispatchableAction(action: "updateDate", payload: nil))
}
let actionController: RMDateSelectionViewController = RMDateSelectionViewController(style: RMActionControllerStyle.black)!
actionController.title = "Select a Date"
// Actions have to be added separately, opposed to in the constructor in order to stack them
actionController.addAction(selectAction! )
actionController.addAction(cancelAction! as! RMAction<UIDatePicker>)
actionController.disableBlurEffects = true
actionController.disableBouncingEffects = true
actionController.datePicker.date = date
actionController.datePicker.datePickerMode = UIDatePicker.Mode.date
self.webViewController!.present(actionController, animated: true, completion: nil)
Is how I'm trying to make it black!
Thanks,
Chris
The key is that you can't set disableBlurEffects = YES, the default NO works well.