Skip to content

Commit db60900

Browse files
author
Ryan Nystrom
committed
make example like things
1 parent ff3271a commit db60900

File tree

3 files changed

+16
-1
lines changed

3 files changed

+16
-1
lines changed

ContextMenu/ClippedContainerViewController.swift

+10
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ internal class ClippedContainerViewController: UIViewController {
1717
self.options = options
1818
self.containedViewController = UINavigationController(rootViewController: viewController)
1919
super.init(nibName: nil, bundle: nil)
20+
self.containedViewController.delegate = self
2021
}
2122

2223
required init?(coder aDecoder: NSCoder) {
@@ -29,6 +30,7 @@ internal class ClippedContainerViewController: UIViewController {
2930
view.layer.shadowRadius = options.containerStyle.shadowRadius
3031
view.layer.shadowOpacity = options.containerStyle.shadowOpacity
3132
view.layer.shadowColor = UIColor.black.cgColor
33+
view.backgroundColor = options.containerStyle.backgroundColor
3234

3335
if options.containerStyle.motionEffect {
3436
let amount = 12
@@ -80,3 +82,11 @@ internal class ClippedContainerViewController: UIViewController {
8082
}
8183

8284
}
85+
86+
extension ClippedContainerViewController: UINavigationControllerDelegate {
87+
88+
func navigationController(_ navigationController: UINavigationController, willShow viewController: UIViewController, animated: Bool) {
89+
viewController.view.backgroundColor = options.containerStyle.backgroundColor
90+
}
91+
92+
}

Example/Example/MenuViewController.swift

+5-1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ class MenuViewController: UITableViewController {
2020
tableView.layoutIfNeeded()
2121
preferredContentSize = CGSize(width: 200, height: tableView.contentSize.height)
2222
navigationItem.backBarButtonItem = UIBarButtonItem(title: " ", style: .plain, target: nil, action: nil)
23+
tableView.backgroundColor = .clear
2324
}
2425

2526
override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
@@ -28,7 +29,10 @@ class MenuViewController: UITableViewController {
2829

2930
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
3031
let cell = tableView.dequeueReusableCell(withIdentifier: "cell", for: indexPath)
31-
cell.textLabel?.text = "Cell \(indexPath.row)"
32+
cell.textLabel?.text = "Option \(indexPath.row)"
33+
cell.textLabel?.font = UIFont.boldSystemFont(ofSize: 17)
34+
cell.textLabel?.textColor = .white
35+
cell.backgroundColor = .clear
3236
cell.accessoryType = .disclosureIndicator
3337
return cell
3438
}

Example/Example/ViewController.swift

+1
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ class ViewController: UIViewController {
2727
ContextMenu.shared.show(
2828
sourceViewController: self,
2929
viewController: MenuViewController(),
30+
options: ContextMenu.Options(containerStyle: ContextMenu.ContainerStyle(backgroundColor: UIColor(red: 41/255.0, green: 45/255.0, blue: 53/255.0, alpha: 1)), menuStyle: .minimal),
3031
sourceView: button
3132
)
3233
}

0 commit comments

Comments
 (0)