diff --git a/CountryPickerView/CountryPickerViewController.swift b/CountryPickerView/CountryPickerViewController.swift index 54a21e2..386d270 100644 --- a/CountryPickerView/CountryPickerViewController.swift +++ b/CountryPickerView/CountryPickerViewController.swift @@ -149,6 +149,10 @@ extension CountryPickerViewController { if let color = dataSource.cellLabelColor { cell.textLabel?.textColor = color } + if let color = dataSource.cellBackgroundColor { + cell.backgroundColor = color + } + cell.selectionStyle = dataSource.cellSelectionStyle cell.accessoryType = country == countryPickerView.selectedCountry && dataSource.showCheckmarkInList ? .checkmark : .none cell.separatorInset = .zero @@ -313,6 +317,10 @@ class CountryPickerViewDataSourceInternal: CountryPickerViewDataSource { return view.dataSource?.cellLabelColor(in: view) } + var cellBackgroundColor: UIColor? { + return view.dataSource?.cellBackgroundColor(in: view) + } + var cellImageViewSize: CGSize { return view.dataSource?.cellImageViewSize(in: view) ?? cellImageViewSize(in: view) } @@ -321,6 +329,10 @@ class CountryPickerViewDataSourceInternal: CountryPickerViewDataSource { return view.dataSource?.cellImageViewCornerRadius(in: view) ?? cellImageViewCornerRadius(in: view) } + var cellSelectionStyle: UITableViewCell.SelectionStyle { + return view.dataSource?.cellSelectionStyle(in: view) ?? .default + } + var navigationTitle: String? { return view.dataSource?.navigationTitle(in: view) } diff --git a/CountryPickerView/Delegate+DataSource.swift b/CountryPickerView/Delegate+DataSource.swift index 076a9ae..7bb8cc3 100644 --- a/CountryPickerView/Delegate+DataSource.swift +++ b/CountryPickerView/Delegate+DataSource.swift @@ -50,12 +50,18 @@ public protocol CountryPickerViewDataSource: class { /// The desired text color for the country names on the list. func cellLabelColor(in countryPickerView: CountryPickerView) -> UIColor? + /// The desired background color for the cell in the list. + func cellBackgroundColor(in countryPickerView: CountryPickerView) -> UIColor? + /// The desired size for the flag images on the list. func cellImageViewSize(in countryPickerView: CountryPickerView) -> CGSize /// The desired corner radius for the flag images on the list. Default value is 2 func cellImageViewCornerRadius(in countryPickerView: CountryPickerView) -> CGFloat + /// The desired cell selection style. + func cellSelectionStyle(in countryPickerView: CountryPickerView) -> UITableViewCell.SelectionStyle + /// The navigation item title when the internal view controller is pushed/presented. func navigationTitle(in countryPickerView: CountryPickerView) -> String? @@ -115,6 +121,10 @@ public extension CountryPickerViewDataSource { return nil } + func cellBackgroundColor(in countryPickerView: CountryPickerView) -> UIColor? { + return nil + } + func cellImageViewCornerRadius(in countryPickerView: CountryPickerView) -> CGFloat { return 2 } @@ -123,6 +133,10 @@ public extension CountryPickerViewDataSource { return CGSize(width: 34, height: 24) } + func cellSelectionStyle(in countryPickerView: CountryPickerView) -> UITableViewCell.SelectionStyle { + return .default + } + func navigationTitle(in countryPickerView: CountryPickerView) -> String? { return nil }