Merge pull request #12 from wickwirew/feature/uiviewcontroller-extension
added view controller show extension
This commit is contained in:
@@ -22,6 +22,7 @@
|
||||
2971CE96205453D900342296 /* SourceViewCorner.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2971CE88205453D900342296 /* SourceViewCorner.swift */; };
|
||||
2971CE97205453D900342296 /* ContextMenuPresenting.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2971CE89205453D900342296 /* ContextMenuPresenting.swift */; };
|
||||
2971CE98205453D900342296 /* CGRect+Area.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2971CE8A205453D900342296 /* CGRect+Area.swift */; };
|
||||
DE5D838B2055D72A0069A81D /* UIViewController+Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = DE5D838A2055D72A0069A81D /* UIViewController+Extensions.swift */; };
|
||||
/* End PBXBuildFile section */
|
||||
|
||||
/* Begin PBXFileReference section */
|
||||
@@ -42,6 +43,7 @@
|
||||
2971CE88205453D900342296 /* SourceViewCorner.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SourceViewCorner.swift; sourceTree = "<group>"; };
|
||||
2971CE89205453D900342296 /* ContextMenuPresenting.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ContextMenuPresenting.swift; sourceTree = "<group>"; };
|
||||
2971CE8A205453D900342296 /* CGRect+Area.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "CGRect+Area.swift"; sourceTree = "<group>"; };
|
||||
DE5D838A2055D72A0069A81D /* UIViewController+Extensions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UIViewController+Extensions.swift"; sourceTree = "<group>"; };
|
||||
/* End PBXFileReference section */
|
||||
|
||||
/* Begin PBXFrameworksBuildPhase section */
|
||||
@@ -90,6 +92,7 @@
|
||||
2971CE89205453D900342296 /* ContextMenuPresenting.swift */,
|
||||
2971CE762054539900342296 /* Info.plist */,
|
||||
2971CE88205453D900342296 /* SourceViewCorner.swift */,
|
||||
DE5D838A2055D72A0069A81D /* UIViewController+Extensions.swift */,
|
||||
);
|
||||
path = ContextMenu;
|
||||
sourceTree = "<group>";
|
||||
@@ -181,6 +184,7 @@
|
||||
2971CE90205453D900342296 /* ContextMenuDismissing.swift in Sources */,
|
||||
2971CE94205453D900342296 /* ContextMenu+MenuStyle.swift in Sources */,
|
||||
2971CE8E205453D900342296 /* ContextMenu+ContainerStyle.swift in Sources */,
|
||||
DE5D838B2055D72A0069A81D /* UIViewController+Extensions.swift in Sources */,
|
||||
2971CE95205453D900342296 /* ClippedContainerViewController.swift in Sources */,
|
||||
2971CE96205453D900342296 /* SourceViewCorner.swift in Sources */,
|
||||
2971CE8F205453D900342296 /* ContextMenu+Item.swift in Sources */,
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
//
|
||||
// UIViewController+Extensions.swift
|
||||
// ContextMenu
|
||||
//
|
||||
// Created by Wes Wickwire on 3/11/18.
|
||||
// Copyright © 2018 Ryan Nystrom. All rights reserved.
|
||||
//
|
||||
|
||||
import UIKit
|
||||
|
||||
|
||||
extension UIViewController {
|
||||
|
||||
/// Show a context menu with given options.
|
||||
///
|
||||
/// - Parameters:
|
||||
/// - viewController: A content view controller to use inside the menu.
|
||||
/// - options: Display and behavior options for a menu.
|
||||
/// - sourceView: A source view for menu context. If nil, menu displays from the center of the screen.
|
||||
public func showContextualMenu(
|
||||
_ viewController: UIViewController,
|
||||
options: ContextMenu.Options = ContextMenu.Options(),
|
||||
sourceView: UIView? = nil
|
||||
) {
|
||||
|
||||
ContextMenu.shared.show(
|
||||
sourceViewController: self,
|
||||
viewController: viewController,
|
||||
options: options,
|
||||
sourceView: sourceView
|
||||
)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user