Skip to content

Commit 3220ba1

Browse files
committed
Update colors for dark mode.
1 parent 7035a6a commit 3220ba1

2 files changed

Lines changed: 31 additions & 20 deletions

File tree

Example/Example/EditorDemoController.swift

Lines changed: 27 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -167,12 +167,23 @@ class EditorDemoController: UIViewController {
167167

168168
edgesForExtendedLayout = UIRectEdge()
169169
navigationController?.navigationBar.isTranslucent = false
170-
171-
view.backgroundColor = .white
172170
view.addSubview(editorView)
173171
view.addSubview(titleTextView)
174172
view.addSubview(titlePlaceholderLabel)
175173
view.addSubview(separatorView)
174+
// color setup
175+
if #available(iOS 13.0, *) {
176+
view.backgroundColor = UIColor.systemBackground
177+
titleTextView.textColor = UIColor.label
178+
editorView.htmlTextView.textColor = UIColor.label
179+
editorView.richTextView.textColor = UIColor.label
180+
editorView.richTextView.blockquoteBackgroundColor = UIColor.tertiarySystemBackground
181+
editorView.richTextView.preBackgroundColor = UIColor.tertiarySystemBackground
182+
var attributes = editorView.richTextView.linkTextAttributes
183+
attributes?[.foregroundColor] = UIColor.link
184+
} else {
185+
view.backgroundColor = UIColor.white
186+
}
176187
//Don't allow scroll while the constraints are being setup and text set
177188
editorView.isScrollEnabled = false
178189
configureConstraints()
@@ -940,11 +951,20 @@ extension EditorDemoController {
940951

941952
let toolbar = Aztec.FormatBar()
942953

943-
toolbar.tintColor = .gray
944-
toolbar.highlightedTintColor = .blue
945-
toolbar.selectedTintColor = view.tintColor
946-
toolbar.disabledTintColor = .lightGray
947-
toolbar.dividerTintColor = .gray
954+
if #available(iOS 13.0, *) {
955+
toolbar.backgroundColor = UIColor.systemGroupedBackground
956+
toolbar.tintColor = UIColor.secondaryLabel
957+
toolbar.highlightedTintColor = UIColor.systemBlue
958+
toolbar.selectedTintColor = UIColor.systemBlue
959+
toolbar.disabledTintColor = .systemGray4
960+
toolbar.dividerTintColor = UIColor.separator
961+
} else {
962+
toolbar.tintColor = .gray
963+
toolbar.highlightedTintColor = .blue
964+
toolbar.selectedTintColor = view.tintColor
965+
toolbar.disabledTintColor = .lightGray
966+
toolbar.dividerTintColor = .gray
967+
}
948968

949969
toolbar.overflowToggleIcon = Gridicon.iconOfType(.ellipsis)
950970
toolbar.frame = CGRect(x: 0, y: 0, width: view.frame.width, height: 44.0)

Example/Example/ViewController.swift

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ class ViewController: UITableViewController
7777
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
7878
let cell = tableView.dequeueReusableCell(withIdentifier: cellIdentifier)!
7979
cell.accessoryType = .disclosureIndicator
80-
80+
//cell.backgroundColor = UIColor.
8181
let row = sections[indexPath.section].rows[indexPath.row]
8282
cell.textLabel?.text = row.title
8383

@@ -87,19 +87,10 @@ class ViewController: UITableViewController
8787
override func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat {
8888
return 40
8989
}
90-
91-
override func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {
92-
let textView = UITextView()
93-
94-
textView.font = UIFont.boldSystemFont(ofSize: 14)
95-
textView.textAlignment = .center
96-
textView.isEditable = false
97-
textView.text = sections[section].title
98-
textView.backgroundColor = UIColor.lightGray
99-
100-
return textView
101-
}
10290

91+
override func tableView(_ tableView: UITableView, titleForHeaderInSection section: Int) -> String? {
92+
return sections[section].title
93+
}
10394

10495
override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
10596
tableView.deselectRow(at: indexPath, animated: true)

0 commit comments

Comments
 (0)