diff --git a/AlertAndPickerUtils.xcodeproj/project.pbxproj b/AlertAndPickerUtils.xcodeproj/project.pbxproj index c1a91f2..44ef9ae 100644 --- a/AlertAndPickerUtils.xcodeproj/project.pbxproj +++ b/AlertAndPickerUtils.xcodeproj/project.pbxproj @@ -714,7 +714,7 @@ PRODUCT_BUNDLE_IDENTIFIER = com.sunflower.AlertAndPickerUtils; PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)"; SKIP_INSTALL = YES; - SWIFT_VERSION = 4.0; + SWIFT_VERSION = 4.2; TARGETED_DEVICE_FAMILY = "1,2"; }; name = Debug; @@ -739,7 +739,7 @@ PRODUCT_BUNDLE_IDENTIFIER = com.sunflower.AlertAndPickerUtils; PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)"; SKIP_INSTALL = YES; - SWIFT_VERSION = 4.0; + SWIFT_VERSION = 4.2; TARGETED_DEVICE_FAMILY = "1,2"; }; name = Release; diff --git a/AlertAndPickerUtils/Extensions/String+Extensions.swift b/AlertAndPickerUtils/Extensions/String+Extensions.swift index a966b9d..4c2d93b 100755 --- a/AlertAndPickerUtils/Extensions/String+Extensions.swift +++ b/AlertAndPickerUtils/Extensions/String+Extensions.swift @@ -13,7 +13,7 @@ public extension String { subscript (r: Range) -> String { let start = index(startIndex, offsetBy: r.lowerBound) let end = index(startIndex, offsetBy: r.upperBound) - return String(self[Range(start ..< end)]) + return String(self[start.. Void)? = nil) { + public func show(animated: Bool = true, vibrate: Bool = false, style: UIBlurEffect.Style? = nil, completion: (() -> Void)? = nil) { /// TODO: change UIBlurEffectStyle if let style = style { @@ -72,7 +72,7 @@ public extension UIAlertController { /// - style: action style (default is UIAlertActionStyle.default) /// - isEnabled: isEnabled status for action (default is true) /// - handler: optional action handler to be called when button is tapped (default is nil) - public func addAction(image: UIImage? = nil, title: String, color: UIColor? = nil, style: UIAlertActionStyle = .default, isEnabled: Bool = true, handler: ((UIAlertAction) -> Void)? = nil) { + public func addAction(image: UIImage? = nil, title: String, color: UIColor? = nil, style: UIAlertAction.Style = .default, isEnabled: Bool = true, handler: ((UIAlertAction) -> Void)? = nil) { //let isPad: Bool = UIDevice.current.userInterfaceIdiom == .pad //let action = UIAlertAction(title: title, style: isPad && style == .cancel ? .default : style, handler: handler) let action = UIAlertAction(title: title, style: style, handler: handler) @@ -106,7 +106,7 @@ public extension UIAlertController { public func setTitle(font: UIFont, color: UIColor) { guard let title = self.title else { return } - let attributes: [NSAttributedStringKey: Any] = [.font: font, .foregroundColor: color] + let attributes: [NSAttributedString.Key: Any] = [.font: font, .foregroundColor: color] let attributedTitle = NSMutableAttributedString(string: title, attributes: attributes) setValue(attributedTitle, forKey: "attributedTitle") } @@ -126,7 +126,7 @@ public extension UIAlertController { public func setMessage(font: UIFont, color: UIColor) { guard let message = self.message else { return } - let attributes: [NSAttributedStringKey: Any] = [.font: font, .foregroundColor: color] + let attributes: [NSAttributedString.Key: Any] = [.font: font, .foregroundColor: color] let attributedMessage = NSMutableAttributedString(string: message, attributes: attributes) setValue(attributedMessage, forKey: "attributedMessage") } diff --git a/AlertAndPickerUtils/Extensions/UIImageView+Extensions.swift b/AlertAndPickerUtils/Extensions/UIImageView+Extensions.swift index 66098eb..7bbb058 100755 --- a/AlertAndPickerUtils/Extensions/UIImageView+Extensions.swift +++ b/AlertAndPickerUtils/Extensions/UIImageView+Extensions.swift @@ -9,7 +9,7 @@ public extension UIImageView { /// - color: This optional paramter sets the background of the image. By default, a random color will be generated. /// - circular: This boolean will determine if the image view will be clipped to a circular shape. /// - textAttributes: This dictionary allows you to specify font, text color, shadow properties, etc. - public func setImage(string: String?, color: UIColor? = nil, circular: Bool = false, textAttributes: [NSAttributedStringKey: Any]? = nil) { + public func setImage(string: String?, color: UIColor? = nil, circular: Bool = false, textAttributes: [NSAttributedString.Key: Any]? = nil) { let image = imageSnap(text: string != nil ? string?.initials : "", color: color ?? UIColor.random, circular: circular, textAttributes: textAttributes) @@ -18,7 +18,7 @@ public extension UIImageView { } } - private func imageSnap(text: String?, color: UIColor, circular: Bool, textAttributes: [NSAttributedStringKey: Any]?) -> UIImage? { + private func imageSnap(text: String?, color: UIColor, circular: Bool, textAttributes: [NSAttributedString.Key: Any]?) -> UIImage? { let scale = Float(UIScreen.main.scale) var size = bounds.size @@ -41,7 +41,7 @@ public extension UIImageView { // Text if let text = text { - let attributes: [NSAttributedStringKey: Any] = textAttributes ?? [.foregroundColor: UIColor.white, .font: UIFont.systemFont(ofSize: 15.0)] + let attributes: [NSAttributedString.Key: Any] = textAttributes ?? [.foregroundColor: UIColor.white, .font: UIFont.systemFont(ofSize: 15.0)] let textSize = text.size(withAttributes: attributes) let bounds = self.bounds @@ -91,24 +91,24 @@ let kGradientBotomOffset: HSVOffset = (hue: 0.025, saturation: -0.05, brightness public extension UIImageView { - public func setImageForName(string: String, backgroundColor: UIColor? = nil, circular: Bool, textAttributes: [NSAttributedStringKey: AnyObject]?, gradient: Bool = false) { + public func setImageForName(string: String, backgroundColor: UIColor? = nil, circular: Bool, textAttributes: [NSAttributedString.Key: AnyObject]?, gradient: Bool = false) { setImageForName(string: string, backgroundColor: backgroundColor, circular: circular, textAttributes: textAttributes, gradient: gradient, gradientColors: nil) } - public func setImageForName(string: String, gradientColors: GradientColors? = nil, circular: Bool = true, textAttributes: [NSAttributedStringKey: AnyObject]? = nil) { + public func setImageForName(string: String, gradientColors: GradientColors? = nil, circular: Bool = true, textAttributes: [NSAttributedString.Key: AnyObject]? = nil) { setImageForName(string: string, backgroundColor: nil, circular: circular, textAttributes: textAttributes, gradient: true, gradientColors: gradientColors) } - public func setImageForName(string: String, backgroundColor: UIColor? = nil, circular: Bool, textAttributes: [NSAttributedStringKey: AnyObject]? = nil, gradient: Bool = false, gradientColors: GradientColors? = nil) { + public func setImageForName(string: String, backgroundColor: UIColor? = nil, circular: Bool, textAttributes: [NSAttributedString.Key: AnyObject]? = nil, gradient: Bool = false, gradientColors: GradientColors? = nil) { let initials: String = initialsFromString(string: string) let color: UIColor = (backgroundColor != nil) ? backgroundColor! : randomColor(for: string) let gradientColors = gradientColors ?? topAndBottomColors(for: color) - let attributes: [NSAttributedStringKey: AnyObject] = (textAttributes != nil) ? textAttributes! : [ - NSAttributedStringKey.font: self.fontForFontName(name: nil), - NSAttributedStringKey.foregroundColor: UIColor.white + let attributes: [NSAttributedString.Key: AnyObject] = (textAttributes != nil) ? textAttributes! : [ + NSAttributedString.Key.font: self.fontForFontName(name: nil), + NSAttributedString.Key.foregroundColor: UIColor.white ] self.image = imageSnapshot(text: initials, backgroundColor: color, circular: circular, textAttributes: attributes, gradient: gradient, gradientColors: gradientColors) @@ -126,7 +126,7 @@ public extension UIImageView { } - private func imageSnapshot(text imageText: String, backgroundColor: UIColor, circular: Bool, textAttributes: [NSAttributedStringKey : AnyObject], gradient: Bool, gradientColors: GradientColors) -> UIImage { + private func imageSnapshot(text imageText: String, backgroundColor: UIColor, circular: Bool, textAttributes: [NSAttributedString.Key : AnyObject], gradient: Bool, gradientColors: GradientColors) -> UIImage { let scale: CGFloat = UIScreen.main.scale diff --git a/AlertAndPickerUtils/Extensions/UISegmentedControl+Extensions.swift b/AlertAndPickerUtils/Extensions/UISegmentedControl+Extensions.swift index 9775cb4..ea7fac4 100755 --- a/AlertAndPickerUtils/Extensions/UISegmentedControl+Extensions.swift +++ b/AlertAndPickerUtils/Extensions/UISegmentedControl+Extensions.swift @@ -4,8 +4,8 @@ public extension UISegmentedControl { /// Font of titles public func title(font: UIFont) { - let attributes: [NSAttributedStringKey: Any] = [.font: font] - setTitleTextAttributes(attributes, for: UIControlState()) + let attributes: [NSAttributedString.Key: Any] = [.font: font] + setTitleTextAttributes(attributes, for: UIControl.State()) //setNeedsDisplay() //layoutIfNeeded() } diff --git a/AlertAndPickerUtils/Extensions/UITextField+Extensions.swift b/AlertAndPickerUtils/Extensions/UITextField+Extensions.swift index 6adb117..ea38b9b 100755 --- a/AlertAndPickerUtils/Extensions/UITextField+Extensions.swift +++ b/AlertAndPickerUtils/Extensions/UITextField+Extensions.swift @@ -12,7 +12,7 @@ public extension UITextField { func left(image: UIImage?, color: UIColor = .black) { if let image = image { - leftViewMode = UITextFieldViewMode.always + leftViewMode = UITextField.ViewMode.always let imageView = UIImageView(frame: CGRect(x: 0, y: 0, width: 20, height: 20)) imageView.contentMode = .scaleAspectFit imageView.image = image @@ -20,14 +20,14 @@ public extension UITextField { imageView.tintColor = color leftView = imageView } else { - leftViewMode = UITextFieldViewMode.never + leftViewMode = UITextField.ViewMode.never leftView = nil } } func right(image: UIImage?, color: UIColor = .black) { if let image = image { - rightViewMode = UITextFieldViewMode.always + rightViewMode = UITextField.ViewMode.always let imageView = UIImageView(frame: CGRect(x: 0, y: 0, width: 20, height: 20)) imageView.contentMode = .scaleAspectFit imageView.image = image @@ -35,7 +35,7 @@ public extension UITextField { imageView.tintColor = color rightView = imageView } else { - rightViewMode = UITextFieldViewMode.never + rightViewMode = UITextField.ViewMode.never rightView = nil } } @@ -49,11 +49,11 @@ public extension UITextField { /// /// - Parameter color: placeholder text color. public func setPlaceHolderTextColor(_ color: UIColor) { - self.attributedPlaceholder = NSAttributedString(string:self.placeholder != nil ? self.placeholder! : "", attributes:[NSAttributedStringKey.foregroundColor: color]) + self.attributedPlaceholder = NSAttributedString(string:self.placeholder != nil ? self.placeholder! : "", attributes:[NSAttributedString.Key.foregroundColor: color]) } /// Set placeholder text and its color func placeholder(text value: String, color: UIColor = .red) { - self.attributedPlaceholder = NSAttributedString(string: value, attributes: [ NSAttributedStringKey.foregroundColor : color]) + self.attributedPlaceholder = NSAttributedString(string: value, attributes: [ NSAttributedString.Key.foregroundColor : color]) } } diff --git a/AlertAndPickerUtils/Pickers/Contacts/ContactsPickerViewController.swift b/AlertAndPickerUtils/Pickers/Contacts/ContactsPickerViewController.swift index aa3433c..dcb840e 100755 --- a/AlertAndPickerUtils/Pickers/Contacts/ContactsPickerViewController.swift +++ b/AlertAndPickerUtils/Pickers/Contacts/ContactsPickerViewController.swift @@ -169,7 +169,7 @@ public class ContactsPickerViewController: UIViewController { let productName = Bundle.main.infoDictionary!["CFBundleName"]! let alert = UIAlertController(style: .alert, title: "Permission denied", message: "\(productName) does not have access to contacts. Please, allow the application to access to your contacts.") alert.addAction(title: "Settings", style: .destructive) { action in - if let settingsURL = URL(string: UIApplicationOpenSettingsURLString) { + if let settingsURL = URL(string: UIApplication.openSettingsURLString) { UIApplication.shared.open(settingsURL) } } diff --git a/AlertAndPickerUtils/Pickers/Contacts/Views/ContactCell.swift b/AlertAndPickerUtils/Pickers/Contacts/Views/ContactCell.swift index ae9d6ee..f733754 100755 --- a/AlertAndPickerUtils/Pickers/Contacts/Views/ContactCell.swift +++ b/AlertAndPickerUtils/Pickers/Contacts/Views/ContactCell.swift @@ -11,7 +11,7 @@ public class ContactTableViewCell: UITableViewCell { // MARK: Initialize - override init(style: UITableViewCellStyle, reuseIdentifier: String?) { + override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) { super.init(style: .subtitle, reuseIdentifier: reuseIdentifier) selectionStyle = .none backgroundColor = nil diff --git a/AlertAndPickerUtils/Pickers/Date/DatePickerViewController.swift b/AlertAndPickerUtils/Pickers/Date/DatePickerViewController.swift index 3ba7b14..3ae8b86 100755 --- a/AlertAndPickerUtils/Pickers/Date/DatePickerViewController.swift +++ b/AlertAndPickerUtils/Pickers/Date/DatePickerViewController.swift @@ -11,7 +11,7 @@ public extension UIAlertController { /// - maximumDate: maximum date of date picker /// - action: an action for datePicker value change - func addDatePicker(mode: UIDatePickerMode, date: Date?, minimumDate: Date? = nil, maximumDate: Date? = nil, action: DatePickerViewController.Action?) { + func addDatePicker(mode: UIDatePicker.Mode, date: Date?, minimumDate: Date? = nil, maximumDate: Date? = nil, action: DatePickerViewController.Action?) { let datePicker = DatePickerViewController(mode: mode, date: date, minimumDate: minimumDate, maximumDate: maximumDate, action: action) set(vc: datePicker, height: 217) } @@ -28,7 +28,7 @@ public class DatePickerViewController: UIViewController { return $0 }(UIDatePicker()) - required public init(mode: UIDatePickerMode, date: Date? = nil, minimumDate: Date? = nil, maximumDate: Date? = nil, action: Action?) { + required public init(mode: UIDatePicker.Mode, date: Date? = nil, minimumDate: Date? = nil, maximumDate: Date? = nil, action: Action?) { super.init(nibName: nil, bundle: Bundle.alertAndPicker) datePicker.datePickerMode = mode datePicker.date = date ?? Date() diff --git a/AlertAndPickerUtils/Pickers/Image/ImagePickerViewController.swift b/AlertAndPickerUtils/Pickers/Image/ImagePickerViewController.swift index 9d91b7d..c92cd12 100755 --- a/AlertAndPickerUtils/Pickers/Image/ImagePickerViewController.swift +++ b/AlertAndPickerUtils/Pickers/Image/ImagePickerViewController.swift @@ -10,7 +10,7 @@ public extension UIAlertController { /// - images: for content to select /// - selection: type and action for selection of image/images - func addImagePicker(flow: UICollectionViewScrollDirection, paging: Bool, images: [UIImage], selection: ImagePickerViewController.SelectionType? = nil) { + func addImagePicker(flow: UICollectionView.ScrollDirection, paging: Bool, images: [UIImage], selection: ImagePickerViewController.SelectionType? = nil) { let vc = ImagePickerViewController(flow: flow, paging: paging, images: images, selection: selection) if UIDevice.current.userInterfaceIdiom == .pad { @@ -68,7 +68,7 @@ public class ImagePickerViewController: UIViewController { $0.register(ItemWithImage.self, forCellWithReuseIdentifier: ItemWithImage.identifier) $0.showsVerticalScrollIndicator = false $0.showsHorizontalScrollIndicator = false - $0.decelerationRate = UIScrollViewDecelerationRateFast + $0.decelerationRate = UIScrollView.DecelerationRate.fast $0.bounces = false $0.backgroundColor = .clear $0.maskToBounds = false @@ -89,7 +89,7 @@ public class ImagePickerViewController: UIViewController { // MARK: Initialize - required public init(flow: UICollectionViewScrollDirection, paging: Bool, images: [UIImage], selection: SelectionType?) { + required public init(flow: UICollectionView.ScrollDirection, paging: Bool, images: [UIImage], selection: SelectionType?) { super.init(nibName: nil, bundle: Bundle.alertAndPicker) self.images = images self.selection = selection diff --git a/AlertAndPickerUtils/Pickers/Locale/LocalePickerViewController.swift b/AlertAndPickerUtils/Pickers/Locale/LocalePickerViewController.swift index ee62936..91b5cae 100755 --- a/AlertAndPickerUtils/Pickers/Locale/LocalePickerViewController.swift +++ b/AlertAndPickerUtils/Pickers/Locale/LocalePickerViewController.swift @@ -84,7 +84,7 @@ public class LocalePickerViewController: UIViewController { fileprivate lazy var indicatorView: UIActivityIndicatorView = { $0.color = .lightGray return $0 - }(UIActivityIndicatorView(activityIndicatorStyle: .whiteLarge)) + }(UIActivityIndicatorView(style: .whiteLarge)) // MARK: Initialize diff --git a/AlertAndPickerUtils/Pickers/Locale/Views/CountryCell.swift b/AlertAndPickerUtils/Pickers/Locale/Views/CountryCell.swift index 6911993..fcbe7b4 100755 --- a/AlertAndPickerUtils/Pickers/Locale/Views/CountryCell.swift +++ b/AlertAndPickerUtils/Pickers/Locale/Views/CountryCell.swift @@ -9,7 +9,7 @@ public class CountryTableViewCell: UITableViewCell { // MARK: Initialize - override init(style: UITableViewCellStyle, reuseIdentifier: String?) { + override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) { super.init(style: .default, reuseIdentifier: reuseIdentifier) selectionStyle = .none backgroundColor = nil diff --git a/AlertAndPickerUtils/Pickers/Locale/Views/CurrencyCell.swift b/AlertAndPickerUtils/Pickers/Locale/Views/CurrencyCell.swift index ce121ff..14843ef 100755 --- a/AlertAndPickerUtils/Pickers/Locale/Views/CurrencyCell.swift +++ b/AlertAndPickerUtils/Pickers/Locale/Views/CurrencyCell.swift @@ -4,7 +4,7 @@ public class CurrencyTableViewCell: UITableViewCell { static let identifier = String(describing: CurrencyTableViewCell.self) - override init(style: UITableViewCellStyle, reuseIdentifier: String?) { + override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) { super.init(style: .subtitle, reuseIdentifier: reuseIdentifier) selectionStyle = .none backgroundColor = nil diff --git a/AlertAndPickerUtils/Pickers/Locale/Views/PhoneCodeCell.swift b/AlertAndPickerUtils/Pickers/Locale/Views/PhoneCodeCell.swift index 8358981..73bcad2 100755 --- a/AlertAndPickerUtils/Pickers/Locale/Views/PhoneCodeCell.swift +++ b/AlertAndPickerUtils/Pickers/Locale/Views/PhoneCodeCell.swift @@ -4,7 +4,7 @@ public class PhoneCodeTableViewCell: UITableViewCell { static let identifier = String(describing: PhoneCodeTableViewCell.self) - override init(style: UITableViewCellStyle, reuseIdentifier: String?) { + override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) { super.init(style: .subtitle, reuseIdentifier: reuseIdentifier) selectionStyle = .none backgroundColor = nil diff --git a/AlertAndPickerUtils/Pickers/Location/LocationPickerViewController.swift b/AlertAndPickerUtils/Pickers/Location/LocationPickerViewController.swift index b83e0d0..ea4a040 100755 --- a/AlertAndPickerUtils/Pickers/Location/LocationPickerViewController.swift +++ b/AlertAndPickerUtils/Pickers/Location/LocationPickerViewController.swift @@ -91,7 +91,7 @@ public class LocationPickerViewController: UIViewController { $0.backgroundColor = UIColor.white.withAlphaComponent(0.8) $0.maskToBounds = true $0.cornerRadius = 22 - $0.setImage(#imageLiteral(resourceName: "geolocation"), for: UIControlState()) + $0.setImage(#imageLiteral(resourceName: "geolocation"), for: UIControl.State()) $0.addTarget(self, action: #selector(LocationPickerViewController.currentLocationPressed), for: .touchUpInside) return $0 @@ -238,7 +238,7 @@ public class LocationPickerViewController: UIViewController { } func showCoordinates(_ coordinate: CLLocationCoordinate2D, animated: Bool = true) { - let region = MKCoordinateRegionMakeWithDistance(coordinate, resultRegionDistance, resultRegionDistance) + let region = MKCoordinateRegion(center: coordinate, latitudinalMeters: resultRegionDistance, longitudinalMeters: resultRegionDistance) mapView.setRegion(region, animated: animated) } @@ -316,7 +316,7 @@ extension LocationPickerViewController: UISearchResultsUpdating { let term = userInfo[LocationPickerViewController.SearchTermKey] as? String else { return } - let request = MKLocalSearchRequest() + let request = MKLocalSearch.Request() request.naturalLanguageQuery = term if let location = locationManager.location, useCurrentLocationAsHint { @@ -331,7 +331,7 @@ extension LocationPickerViewController: UISearchResultsUpdating { } } - func showItemsForSearchResult(_ searchResult: MKLocalSearchResponse?) { + func showItemsForSearchResult(_ searchResult: MKLocalSearch.Response?) { results.locations = searchResult?.mapItems.map { Location(name: $0.name, placemark: $0.placemark) } ?? [] results.isShowingHistory = false results.tableView.reloadData() @@ -384,13 +384,13 @@ extension LocationPickerViewController: MKMapViewDelegate { func selectLocationButton() -> UIButton { let button = UIButton(frame: CGRect(x: 0, y: 0, width: 70, height: 30)) - button.setTitle(selectButtonTitle, for: UIControlState()) + button.setTitle(selectButtonTitle, for: UIControl.State()) if let titleLabel = button.titleLabel { let width = titleLabel.textRect(forBounds: CGRect(x: 0, y: 0, width: Int.max, height: 30), limitedToNumberOfLines: 1).width button.frame.size = CGSize(width: width + 10, height: 30.0) } button.backgroundColor = UIColor(hex: 0x007AFF) - button.setTitleColor(.white, for: UIControlState()) + button.setTitleColor(.white, for: UIControl.State()) button.borderWidth = 2 button.borderColor = UIColor(hex: 0x007AFF) button.cornerRadius = 5 diff --git a/AlertAndPickerUtils/Pickers/PhotoLibrary/PhotoLibraryPickerViewController.swift b/AlertAndPickerUtils/Pickers/PhotoLibrary/PhotoLibraryPickerViewController.swift index a66390c..01af043 100755 --- a/AlertAndPickerUtils/Pickers/PhotoLibrary/PhotoLibraryPickerViewController.swift +++ b/AlertAndPickerUtils/Pickers/PhotoLibrary/PhotoLibraryPickerViewController.swift @@ -12,7 +12,7 @@ public extension UIAlertController { /// - images: for content to select /// - selection: type and action for selection of image/images - func addPhotoLibraryPicker(flow: UICollectionViewScrollDirection, paging: Bool, selection: PhotoLibraryPickerViewController.Selection) { + func addPhotoLibraryPicker(flow: UICollectionView.ScrollDirection, paging: Bool, selection: PhotoLibraryPickerViewController.Selection) { let selection: PhotoLibraryPickerViewController.Selection = selection var asset: PHAsset? var assets: [PHAsset] = [] @@ -96,7 +96,7 @@ public class PhotoLibraryPickerViewController: UIViewController { $0.register(ItemWithImage.self, forCellWithReuseIdentifier: String(describing: ItemWithImage.self)) $0.showsVerticalScrollIndicator = false $0.showsHorizontalScrollIndicator = false - $0.decelerationRate = UIScrollViewDecelerationRateFast + $0.decelerationRate = .fast $0.bounces = true $0.backgroundColor = .clear $0.maskToBounds = false @@ -117,7 +117,7 @@ public class PhotoLibraryPickerViewController: UIViewController { // MARK: Initialize - required public init(flow: UICollectionViewScrollDirection, paging: Bool, selection: Selection) { + required public init(flow: UICollectionView.ScrollDirection, paging: Bool, selection: Selection) { super.init(nibName: nil, bundle: Bundle.alertAndPicker) self.selection = selection @@ -177,9 +177,9 @@ public class PhotoLibraryPickerViewController: UIViewController { case .denied, .restricted: /// User has denied the current app to access the contacts. let productName = Bundle.main.infoDictionary!["CFBundleName"]! - let alert = UIAlertController(style: .alert, title: "Permission denied", message: "\(productName) does not have access to contacts. Please, allow the application to access to your photo library.") + let alert = UIAlertController(title: "Permission denied", message: "\(productName) does not have access to contacts. Please, allow the application to access to your photo library.", preferredStyle: .alert) alert.addAction(title: "Settings", style: .destructive) { action in - if let settingsURL = URL(string: UIApplicationOpenSettingsURLString) { + if let settingsURL = URL(string: UIApplication.openSettingsURLString) { UIApplication.shared.open(settingsURL) } } @@ -198,7 +198,7 @@ public class PhotoLibraryPickerViewController: UIViewController { completionHandler(assets) case .error(let error): - let alert = UIAlertController(style: .alert, title: "Error", message: error.localizedDescription) + let alert = UIAlertController(title: "Error", message: error.localizedDescription, preferredStyle: .alert) alert.addAction(title: "OK") { [unowned self] action in self.alertController?.dismiss(animated: true) } diff --git a/AlertAndPickerUtils/Pickers/Telegram/TelegramPickerViewController.swift b/AlertAndPickerUtils/Pickers/Telegram/TelegramPickerViewController.swift index d380cb9..5cedfc4 100755 --- a/AlertAndPickerUtils/Pickers/Telegram/TelegramPickerViewController.swift +++ b/AlertAndPickerUtils/Pickers/Telegram/TelegramPickerViewController.swift @@ -102,7 +102,7 @@ public class TelegramPickerViewController: UIViewController { $0.allowsMultipleSelection = true $0.showsVerticalScrollIndicator = false $0.showsHorizontalScrollIndicator = false - $0.decelerationRate = UIScrollViewDecelerationRateFast + $0.decelerationRate = UIScrollView.DecelerationRate.fast $0.contentInset = UI.insets $0.backgroundColor = .clear $0.maskToBounds = false @@ -209,9 +209,9 @@ public class TelegramPickerViewController: UIViewController { case .denied, .restricted: /// User has denied the current app to access the contacts. let productName = Bundle.main.infoDictionary!["CFBundleName"]! - let alert = UIAlertController(style: .alert, title: "Permission denied", message: "\(productName) does not have access to contacts. Please, allow the application to access to your photo library.") + let alert = UIAlertController(title: "Permission denied", message: "\(productName) does not have access to contacts. Please, allow the application to access to your photo library.", preferredStyle: .alert) alert.addAction(title: "Settings", style: .destructive) { action in - if let settingsURL = URL(string: UIApplicationOpenSettingsURLString) { + if let settingsURL = URL(string: UIApplication.openSettingsURLString) { UIApplication.shared.open(settingsURL) } } @@ -231,7 +231,7 @@ public class TelegramPickerViewController: UIViewController { case .error(let error): Log("------ error") - let alert = UIAlertController(style: .alert, title: "Error", message: error.localizedDescription) + let alert = UIAlertController(title: "Error", message: error.localizedDescription, preferredStyle: .alert) alert.addAction(title: "OK") { [unowned self] action in self.alertController?.dismiss(animated: true) } diff --git a/AlertAndPickerUtils/Pickers/Telegram/Views/LikeButtonCell.swift b/AlertAndPickerUtils/Pickers/Telegram/Views/LikeButtonCell.swift index 69d2798..8c055f9 100755 --- a/AlertAndPickerUtils/Pickers/Telegram/Views/LikeButtonCell.swift +++ b/AlertAndPickerUtils/Pickers/Telegram/Views/LikeButtonCell.swift @@ -9,7 +9,7 @@ public class LikeButtonCell: UITableViewCell { // MARK: Initialize - override init(style: UITableViewCellStyle, reuseIdentifier: String?) { + override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) { super.init(style: .default, reuseIdentifier: reuseIdentifier) selectionStyle = .none backgroundColor = nil diff --git a/AlertAndPickerUtils/Viewers/Models/AttributedTextBlock.swift b/AlertAndPickerUtils/Viewers/Models/AttributedTextBlock.swift index e6c3c71..113549e 100755 --- a/AlertAndPickerUtils/Viewers/Models/AttributedTextBlock.swift +++ b/AlertAndPickerUtils/Viewers/Models/AttributedTextBlock.swift @@ -11,16 +11,16 @@ public enum AttributedTextBlock { let attributedString: NSMutableAttributedString switch self { case .header1(let value): - let attributes: [NSAttributedStringKey: Any] = [.font: UIFont.boldSystemFont(ofSize: 20), .foregroundColor: UIColor.black] + let attributes: [NSAttributedString.Key: Any] = [.font: UIFont.boldSystemFont(ofSize: 20), .foregroundColor: UIColor.black] attributedString = NSMutableAttributedString(string: value, attributes: attributes) case .header2(let value): - let attributes: [NSAttributedStringKey: Any] = [.font: UIFont.boldSystemFont(ofSize: 18), .foregroundColor: UIColor.black] + let attributes: [NSAttributedString.Key: Any] = [.font: UIFont.boldSystemFont(ofSize: 18), .foregroundColor: UIColor.black] attributedString = NSMutableAttributedString(string: value, attributes: attributes) case .normal(let value): - let attributes: [NSAttributedStringKey: Any] = [.font: UIFont.systemFont(ofSize: 15), .foregroundColor: UIColor.black] + let attributes: [NSAttributedString.Key: Any] = [.font: UIFont.systemFont(ofSize: 15), .foregroundColor: UIColor.black] attributedString = NSMutableAttributedString(string: value, attributes: attributes) case .list(let value): - let attributes: [NSAttributedStringKey: Any] = [.font: UIFont.systemFont(ofSize: 15), .foregroundColor: UIColor.black] + let attributes: [NSAttributedString.Key: Any] = [.font: UIFont.systemFont(ofSize: 15), .foregroundColor: UIColor.black] attributedString = NSMutableAttributedString(string: "∙ " + value, attributes: attributes) } let paragraphStyle = NSMutableParagraphStyle() diff --git a/AlertAndPickerUtils/Viewers/TextViewController.swift b/AlertAndPickerUtils/Viewers/TextViewController.swift index f9975a0..e3b6c67 100755 --- a/AlertAndPickerUtils/Viewers/TextViewController.swift +++ b/AlertAndPickerUtils/Viewers/TextViewController.swift @@ -46,7 +46,7 @@ public class TextViewerViewController: UIViewController { case .attributedText(let text): textView.attributedText = text.map { $0.text }.joined(separator: "\n") } - textView.textContainerInset = UIEdgeInsetsMake(UI.hInset, UI.vInset, UI.hInset, UI.vInset) + textView.textContainerInset = UIEdgeInsets(top: UI.hInset, left: UI.vInset, bottom: UI.hInset, right: UI.vInset) //preferredContentSize.height = self.textView.contentSize.height } diff --git a/AlertAndPickerUtils/Views/GradientSlider.swift b/AlertAndPickerUtils/Views/GradientSlider.swift index b2c0ed4..9cfa1c3 100755 --- a/AlertAndPickerUtils/Views/GradientSlider.swift +++ b/AlertAndPickerUtils/Views/GradientSlider.swift @@ -276,11 +276,11 @@ import UIKit //MARK: - Layout override open var intrinsicContentSize: CGSize { - return CGSize(width: UIViewNoIntrinsicMetric, height: thumbSize) + return CGSize(width: UIView.noIntrinsicMetric, height: thumbSize) } override open var alignmentRectInsets: UIEdgeInsets { - return UIEdgeInsetsMake(4.0, 2.0, 4.0, 2.0) + return UIEdgeInsets(top: 4.0, left: 2.0, bottom: 4.0, right: 2.0) } override open func layoutSublayers(of layer: CALayer) { @@ -358,7 +358,7 @@ import UIKit set(value: newValue, animated: false) } actionBlock(self,_value) - sendActions(for: [UIControlEvents.valueChanged, UIControlEvents.touchUpInside]) + sendActions(for: [UIControl.Event.valueChanged, UIControl.Event.touchUpInside]) } diff --git a/AlertAndPickerUtils/Views/Label.swift b/AlertAndPickerUtils/Views/Label.swift index c7e9f00..b23b1ec 100755 --- a/AlertAndPickerUtils/Views/Label.swift +++ b/AlertAndPickerUtils/Views/Label.swift @@ -9,7 +9,7 @@ open class Label: UILabel { open var insets: UIEdgeInsets = .zero override open func drawText(in rect: CGRect) { - super.drawText(in: UIEdgeInsetsInsetRect(rect, insets)) + super.drawText(in: rect.inset(by: insets)) } // Override -intrinsicContentSize: for Auto layout code