Skip to content
This repository has been archived by the owner on Feb 8, 2023. It is now read-only.

Commit

Permalink
support customize background color and separator color
Browse files Browse the repository at this point in the history
  • Loading branch information
hongxinhope committed May 18, 2016
1 parent 309f3af commit 434a8b1
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 3 deletions.
8 changes: 8 additions & 0 deletions RecurrencePicker/CustomRecurrenceViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ internal class CustomRecurrenceViewController: UITableViewController {
internal var occurrenceDate: NSDate!
internal var tintColor: UIColor!
internal var recurrenceRule: RecurrenceRule!
internal var backgroundColor: UIColor?
internal var separatorColor: UIColor?

private var isShowingPickerView = false
private var pickerViewStyle: PickerViewCellStyle = .Frequency
Expand Down Expand Up @@ -308,6 +310,12 @@ extension CustomRecurrenceViewController {
navigationItem.title = LocalizedString(key: "RecurrencePicker.textLabel.custom")
navigationController?.navigationBar.tintColor = tintColor
tableView.tintColor = tintColor
if let backgroundColor = backgroundColor {
tableView.backgroundColor = backgroundColor
}
if let separatorColor = separatorColor {
tableView.separatorColor = separatorColor
}

let bundle = NSBundle(identifier: "Teambition.RecurrencePicker") ?? NSBundle.mainBundle()
tableView.registerNib(UINib(nibName: "PickerViewCell", bundle: bundle), forCellReuseIdentifier: CellID.pickerViewCell)
Expand Down
10 changes: 10 additions & 0 deletions RecurrencePicker/RecurrencePicker.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ public class RecurrencePicker: UITableViewController {
public var tintColor = UIColor.blueColor()
public var calendar = NSCalendar.currentCalendar()
public var occurrenceDate = NSDate()
public var backgroundColor: UIColor?
public var separatorColor: UIColor?

private var recurrenceRule: RecurrenceRule?
private var selectedIndexPath = NSIndexPath(forRow: 0, inSection: 0)
Expand Down Expand Up @@ -132,6 +134,8 @@ extension RecurrencePicker {
let customRecurrenceViewController = CustomRecurrenceViewController(style: .Grouped)
customRecurrenceViewController.occurrenceDate = occurrenceDate
customRecurrenceViewController.tintColor = tintColor
customRecurrenceViewController.backgroundColor = backgroundColor
customRecurrenceViewController.separatorColor = separatorColor
customRecurrenceViewController.delegate = self

var rule = recurrenceRule ?? RecurrenceRule.dailyRecurrence()
Expand Down Expand Up @@ -163,6 +167,12 @@ extension RecurrencePicker {
navigationItem.title = LocalizedString(key: "RecurrencePicker.navigation.title")
navigationController?.navigationBar.tintColor = tintColor
tableView.tintColor = tintColor
if let backgroundColor = backgroundColor {
tableView.backgroundColor = backgroundColor
}
if let separatorColor = separatorColor {
tableView.separatorColor = separatorColor
}
updateSelectedIndexPath(withRule: recurrenceRule)
}

Expand Down
2 changes: 1 addition & 1 deletion RecurrencePicker/Supporting Files/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>0.0.3</string>
<string>0.0.4</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
Expand Down
2 changes: 2 additions & 0 deletions RecurrencePickerExample/ExampleViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ class ExampleViewController: UIViewController {
recurrencePicker.tintColor = kTBBlueColor
recurrencePicker.language = language
recurrencePicker.occurrenceDate = occurrenceDate
recurrencePicker.backgroundColor = UIColor(white: 242 / 255, alpha: 1)
recurrencePicker.separatorColor = UIColor(white: 221 / 255, alpha: 1)
recurrencePicker.delegate = self
navigationController?.pushViewController(recurrencePicker, animated: true)
}
Expand Down
4 changes: 2 additions & 2 deletions RecurrencePickerExample/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>0.0.3</string>
<string>0.0.4</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>3</string>
<string>4</string>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>UILaunchStoryboardName</key>
Expand Down

0 comments on commit 434a8b1

Please sign in to comment.