diff --git a/DatePickerDialog.xcodeproj/project.pbxproj b/DatePickerDialog.xcodeproj/project.pbxproj index b9e981f..ae7e355 100644 --- a/DatePickerDialog.xcodeproj/project.pbxproj +++ b/DatePickerDialog.xcodeproj/project.pbxproj @@ -230,6 +230,7 @@ developmentRegion = English; hasScannedForEncodings = 0; knownRegions = ( + English, en, Base, ); @@ -458,20 +459,21 @@ buildSettings = { CLANG_ENABLE_MODULES = YES; CODE_SIGN_IDENTITY = ""; + COPY_PHASE_STRIP = YES; DEFINES_MODULE = YES; DYLIB_COMPATIBILITY_VERSION = 1; DYLIB_CURRENT_VERSION = 1; DYLIB_INSTALL_NAME_BASE = "@rpath"; INFOPLIST_FILE = Sources/Info.plist; INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; - IPHONEOS_DEPLOYMENT_TARGET = 8.0; + IPHONEOS_DEPLOYMENT_TARGET = 10.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = squimer.DatePickerDialog; PRODUCT_NAME = "$(TARGET_NAME)"; SKIP_INSTALL = YES; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; SWIFT_SWIFT3_OBJC_INFERENCE = Default; - SWIFT_VERSION = 4.0; + SWIFT_VERSION = 5.3; }; name = Debug; }; @@ -480,19 +482,20 @@ buildSettings = { CLANG_ENABLE_MODULES = YES; CODE_SIGN_IDENTITY = ""; + COPY_PHASE_STRIP = YES; DEFINES_MODULE = YES; DYLIB_COMPATIBILITY_VERSION = 1; DYLIB_CURRENT_VERSION = 1; DYLIB_INSTALL_NAME_BASE = "@rpath"; INFOPLIST_FILE = Sources/Info.plist; INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; - IPHONEOS_DEPLOYMENT_TARGET = 8.0; + IPHONEOS_DEPLOYMENT_TARGET = 10.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = squimer.DatePickerDialog; PRODUCT_NAME = "$(TARGET_NAME)"; SKIP_INSTALL = YES; SWIFT_SWIFT3_OBJC_INFERENCE = Default; - SWIFT_VERSION = 4.0; + SWIFT_VERSION = 5.3; }; name = Release; }; diff --git a/Sources/DatePickerDialog.swift b/Sources/DatePickerDialog.swift index 880479d..e59820c 100644 --- a/Sources/DatePickerDialog.swift +++ b/Sources/DatePickerDialog.swift @@ -24,7 +24,7 @@ open class DatePickerDialog: UIView { // MARK: - Variables private var defaultDate: Date? - private var datePickerMode: UIDatePickerMode? + private var datePickerMode: UIDatePicker.Mode? private var callback: DatePickerCallback? var showCancelButton: Bool = false var locale: Locale? @@ -73,7 +73,7 @@ open class DatePickerDialog: UIView { /// Handle device orientation changes @objc func deviceOrientationDidChange(_ notification: Notification) { self.frame = UIScreen.main.bounds - let dialogSize = CGSize(width: 300, height: 230 + kDefaultButtonHeight + kDefaultButtonSpacerHeight) + let dialogSize = CGSize(width: UIScreen.main.bounds.size.width - 10, height: 230 + kDefaultButtonHeight + kDefaultButtonSpacerHeight) dialogView.frame = CGRect(x: (UIScreen.main.bounds.size.width - dialogSize.width) / 2, y: (UIScreen.main.bounds.size.height - dialogSize.height) / 2, width: dialogSize.width, @@ -86,7 +86,7 @@ open class DatePickerDialog: UIView { cancelButtonTitle: String = "Cancel", defaultDate: Date = Date(), minimumDate: Date? = nil, maximumDate: Date? = nil, - datePickerMode: UIDatePickerMode = .dateAndTime, + datePickerMode: UIDatePicker.Mode = .dateAndTime, callback: @escaping DatePickerCallback) { self.titleLabel.text = title self.doneButton.setTitle(doneButtonTitle, for: .normal) @@ -96,7 +96,7 @@ open class DatePickerDialog: UIView { self.datePickerMode = datePickerMode self.callback = callback self.defaultDate = defaultDate - self.datePicker.datePickerMode = self.datePickerMode ?? UIDatePickerMode.date + self.datePicker.datePickerMode = self.datePickerMode ?? UIDatePicker.Mode.date self.datePicker.date = self.defaultDate ?? Date() self.datePicker.maximumDate = maximumDate self.datePicker.minimumDate = minimumDate @@ -107,12 +107,12 @@ open class DatePickerDialog: UIView { guard let appDelegate = UIApplication.shared.delegate else { fatalError() } guard let window = appDelegate.window else { fatalError() } window?.addSubview(self) - window?.bringSubview(toFront: self) + window?.bringSubviewToFront(self) window?.endEditing(true) NotificationCenter.default.addObserver(self, selector: .deviceOrientationDidChange, - name: NSNotification.Name.UIDeviceOrientationDidChange, object: nil) + name: UIDevice.orientationDidChangeNotification, object: nil) /* Anim */ UIView.animate( @@ -159,7 +159,7 @@ open class DatePickerDialog: UIView { /// Creates the container view here: create the dialog, then add the custom content and buttons private func createContainerView() -> UIView { let screenSize = UIScreen.main.bounds.size - let dialogSize = CGSize(width: 300, height: 230 + kDefaultButtonHeight + kDefaultButtonSpacerHeight) + let dialogSize = CGSize(width: UIScreen.main.bounds.size.width - 10, height: 230 + kDefaultButtonHeight + kDefaultButtonSpacerHeight) // For the black background self.frame = CGRect(x: 0, y: 0, width: screenSize.width, height: screenSize.height) @@ -220,7 +220,7 @@ open class DatePickerDialog: UIView { let datePicker = UIDatePicker(frame: CGRect(x: 0, y: 30, width: 0, height: 0)) datePicker.setValue(self.textColor, forKeyPath: "textColor") datePicker.autoresizingMask = .flexibleRightMargin - datePicker.frame.size.width = 300 + datePicker.frame.size.width = UIScreen.main.bounds.size.width - 10 datePicker.frame.size.height = 216 return datePicker }