6 Commits

Author SHA1 Message Date
Bas Broek 2e94b10a95 Ignore motion effect if reduce motion is turned on 2018-03-14 21:14:40 +01:00
Ryan Nystrom 93e12a4b16 Merge pull request #14 from kidap/add-carthage-support
Add carthage support
2018-03-13 22:56:01 -04:00
Karlo Pagtakhan 8572bf3969 Updated README.md to add carthage instructions 2018-03-13 10:12:56 -04:00
Karlo Pagtakhan 33b58dbbde Made schemes shared to support Carthage 2018-03-13 10:09:27 -04:00
Ryan Nystrom bf7cd281f7 Merge pull request #12 from wickwirew/feature/uiviewcontroller-extension
added view controller show extension
2018-03-11 23:18:41 -04:00
Wesley Wickwire 998ecaca42 added view controller show extension 2018-03-11 17:34:41 -04:00
6 changed files with 125 additions and 1 deletions
+4
View File
@@ -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,82 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0920"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "2971CE712054539900342296"
BuildableName = "ContextMenu.framework"
BlueprintName = "ContextMenu"
ReferencedContainer = "container:ContextMenu.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
language = ""
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
</Testables>
<AdditionalOptions>
</AdditionalOptions>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
language = ""
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES">
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "2971CE712054539900342296"
BuildableName = "ContextMenu.framework"
BlueprintName = "ContextMenu"
ReferencedContainer = "container:ContextMenu.xcodeproj">
</BuildableReference>
</MacroExpansion>
<AdditionalOptions>
</AdditionalOptions>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES">
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "2971CE712054539900342296"
BuildableName = "ContextMenu.framework"
BlueprintName = "ContextMenu"
ReferencedContainer = "container:ContextMenu.xcodeproj">
</BuildableReference>
</MacroExpansion>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>
@@ -32,7 +32,7 @@ class ClippedContainerViewController: UIViewController {
view.layer.shadowColor = UIColor.black.cgColor
view.backgroundColor = options.containerStyle.backgroundColor
if options.containerStyle.motionEffect {
if options.containerStyle.motionEffect && UIAccessibilityIsReduceMotionEnabled() == false {
let amount = 12
let tiltX = UIInterpolatingMotionEffect(keyPath: "center.x", type: .tiltAlongHorizontalAxis)
tiltX.minimumRelativeValue = -amount
@@ -38,6 +38,7 @@ extension ContextMenu {
public let overlayColor: UIColor
/// A flag indicating if device gyro effects should be applied.
/// If the user has enabled Reduce Motion in Settings, this will be ignored.
public let motionEffect: Bool
public init(
@@ -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
)
}
}
+4
View File
@@ -13,6 +13,10 @@ Just add `ContextMenu` to your Podfile and `pod install`. Done!
```ruby
pod 'ContextMenu'
```
For Carthage, just add `GitHawkApp/ContextMenu` to your Cartfile and `carthage bootstrap`.
```ogdl
github "GitHawkApp/ContextMenu"
```
## Usage