Skip to content

Commit

Permalink
make example like things
Browse files Browse the repository at this point in the history
  • Loading branch information
Ryan Nystrom committed Mar 10, 2018
1 parent ff3271a commit db60900
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 1 deletion.
10 changes: 10 additions & 0 deletions ContextMenu/ClippedContainerViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ internal class ClippedContainerViewController: UIViewController {
self.options = options
self.containedViewController = UINavigationController(rootViewController: viewController)
super.init(nibName: nil, bundle: nil)
self.containedViewController.delegate = self
}

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

if options.containerStyle.motionEffect {
let amount = 12
Expand Down Expand Up @@ -80,3 +82,11 @@ internal class ClippedContainerViewController: UIViewController {
}

}

extension ClippedContainerViewController: UINavigationControllerDelegate {

func navigationController(_ navigationController: UINavigationController, willShow viewController: UIViewController, animated: Bool) {
viewController.view.backgroundColor = options.containerStyle.backgroundColor
}

}
6 changes: 5 additions & 1 deletion Example/Example/MenuViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ class MenuViewController: UITableViewController {
tableView.layoutIfNeeded()
preferredContentSize = CGSize(width: 200, height: tableView.contentSize.height)
navigationItem.backBarButtonItem = UIBarButtonItem(title: " ", style: .plain, target: nil, action: nil)
tableView.backgroundColor = .clear
}

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

override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "cell", for: indexPath)
cell.textLabel?.text = "Cell \(indexPath.row)"
cell.textLabel?.text = "Option \(indexPath.row)"
cell.textLabel?.font = UIFont.boldSystemFont(ofSize: 17)
cell.textLabel?.textColor = .white
cell.backgroundColor = .clear
cell.accessoryType = .disclosureIndicator
return cell
}
Expand Down
1 change: 1 addition & 0 deletions Example/Example/ViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ class ViewController: UIViewController {
ContextMenu.shared.show(
sourceViewController: self,
viewController: MenuViewController(),
options: ContextMenu.Options(containerStyle: ContextMenu.ContainerStyle(backgroundColor: UIColor(red: 41/255.0, green: 45/255.0, blue: 53/255.0, alpha: 1)), menuStyle: .minimal),
sourceView: button
)
}
Expand Down

0 comments on commit db60900

Please sign in to comment.