├── .gitignore ├── ContextMenu.xcodeproj ├── project.pbxproj └── project.xcworkspace │ ├── contents.xcworkspacedata │ └── xcshareddata │ └── IDEWorkspaceChecks.plist ├── ContextMenu ├── Application │ ├── AppDelegate.swift │ └── SceneDelegate.swift ├── Assets │ ├── Assets.xcassets │ │ ├── AppIcon.appiconset │ │ │ └── Contents.json │ │ ├── Contents.json │ │ └── images │ │ │ ├── Contents.json │ │ │ ├── bridge.imageset │ │ │ ├── Contents.json │ │ │ └── bridge.jpeg │ │ │ ├── flowers.imageset │ │ │ ├── Contents.json │ │ │ └── flowers.jpeg │ │ │ ├── mountains.imageset │ │ │ ├── Contents.json │ │ │ └── mountains.jpeg │ │ │ ├── rock.imageset │ │ │ ├── Contents.json │ │ │ └── rock.jpeg │ │ │ ├── skis.imageset │ │ │ ├── Contents.json │ │ │ └── skis.jpeg │ │ │ ├── street.imageset │ │ │ ├── Contents.json │ │ │ └── street.jpeg │ │ │ └── sunset.imageset │ │ │ ├── Contents.json │ │ │ └── sunset.jpeg │ ├── Base.lproj │ │ └── LaunchScreen.storyboard │ └── Info.plist └── Context Menu Demo │ ├── Basic Menus │ ├── CollectionViewController.swift │ ├── SingleViewController.swift │ └── TableViewController.swift │ ├── CatalogViewController.swift │ ├── ContextMenuDemo.swift │ ├── Fixtures.swift │ └── More Features │ ├── Custom Previews │ ├── TargetedPreviewViewController.swift │ ├── VCPreviewCollectionViewController.swift │ ├── VCPreviewSingleViewController.swift │ └── VCTargetedPreviewViewController.swift │ └── Submenus │ ├── InlineSubmenuViewController.swift │ └── SubmenuViewController.swift ├── README.md └── images ├── collection.png ├── nesting.png ├── photo.png ├── targeted-1.png └── targeted-2.png /.gitignore: -------------------------------------------------------------------------------- 1 | # Xcode 2 | # 3 | # gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore 4 | 5 | ## Build generated 6 | build/ 7 | DerivedData/ 8 | 9 | ## Various settings 10 | *.pbxuser 11 | !default.pbxuser 12 | *.mode1v3 13 | !default.mode1v3 14 | *.mode2v3 15 | !default.mode2v3 16 | *.perspectivev3 17 | !default.perspectivev3 18 | xcuserdata/ 19 | 20 | ## Other 21 | *.moved-aside 22 | *.xccheckout 23 | *.xcscmblueprint 24 | 25 | ## Obj-C/Swift specific 26 | *.hmap 27 | *.ipa 28 | *.dSYM.zip 29 | *.dSYM 30 | 31 | ## Playgrounds 32 | timeline.xctimeline 33 | playground.xcworkspace 34 | 35 | # Swift Package Manager 36 | # 37 | # Add this line if you want to avoid checking in source code from Swift Package Manager dependencies. 38 | # Packages/ 39 | # Package.pins 40 | # Package.resolved 41 | .build/ 42 | 43 | # CocoaPods 44 | # 45 | # We recommend against adding the Pods directory to your .gitignore. However 46 | # you should judge for yourself, the pros and cons are mentioned at: 47 | # https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control 48 | # 49 | # Pods/ 50 | 51 | # Carthage 52 | # 53 | # Add this line if you want to avoid checking in source code from Carthage dependencies. 54 | # Carthage/Checkouts 55 | 56 | Carthage/Build 57 | 58 | # fastlane 59 | # 60 | # It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the 61 | # screenshots whenever they are needed. 62 | # For more information about the recommended setup visit: 63 | # https://docs.fastlane.tools/best-practices/source-control/#source-control 64 | 65 | fastlane/report.xml 66 | fastlane/Preview.html 67 | fastlane/screenshots/**/*.png 68 | fastlane/test_output 69 | -------------------------------------------------------------------------------- /ContextMenu.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 50; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 2772A8B6230CA2140017442F /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2772A8B5230CA2140017442F /* AppDelegate.swift */; }; 11 | 2772A8B8230CA2140017442F /* SceneDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2772A8B7230CA2140017442F /* SceneDelegate.swift */; }; 12 | 2772A8BA230CA2140017442F /* CatalogViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2772A8B9230CA2140017442F /* CatalogViewController.swift */; }; 13 | 2772A8BF230CA2150017442F /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 2772A8BE230CA2150017442F /* Assets.xcassets */; }; 14 | 2772A8C2230CA2150017442F /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 2772A8C0230CA2150017442F /* LaunchScreen.storyboard */; }; 15 | 2772A8CF230CA3700017442F /* SingleViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2772A8CE230CA3700017442F /* SingleViewController.swift */; }; 16 | 2772A8D1230CA7970017442F /* ContextMenuDemo.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2772A8D0230CA7970017442F /* ContextMenuDemo.swift */; }; 17 | 2772A8D3230CA8E60017442F /* CollectionViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2772A8D2230CA8E60017442F /* CollectionViewController.swift */; }; 18 | 2773BA33230DB99300D08658 /* VCPreviewCollectionViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2773BA32230DB99300D08658 /* VCPreviewCollectionViewController.swift */; }; 19 | 2773BA35230DBB2B00D08658 /* Fixtures.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2773BA34230DBB2B00D08658 /* Fixtures.swift */; }; 20 | 2773BA37230DBC2E00D08658 /* VCTargetedPreviewViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2773BA36230DBC2E00D08658 /* VCTargetedPreviewViewController.swift */; }; 21 | 27C8E10C230CF4550047E4EB /* VCPreviewSingleViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 27C8E10B230CF4550047E4EB /* VCPreviewSingleViewController.swift */; }; 22 | 27D091F9230CE7D800C5B2FF /* TableViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 27D091F8230CE7D800C5B2FF /* TableViewController.swift */; }; 23 | 27D091FD230CEAC100C5B2FF /* SubmenuViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 27D091FC230CEAC100C5B2FF /* SubmenuViewController.swift */; }; 24 | 27D091FF230CEB9600C5B2FF /* InlineSubmenuViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 27D091FE230CEB9600C5B2FF /* InlineSubmenuViewController.swift */; }; 25 | 27D09201230CEC5D00C5B2FF /* TargetedPreviewViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 27D09200230CEC5D00C5B2FF /* TargetedPreviewViewController.swift */; }; 26 | /* End PBXBuildFile section */ 27 | 28 | /* Begin PBXFileReference section */ 29 | 2772A8B2230CA2140017442F /* ContextMenu.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = ContextMenu.app; sourceTree = BUILT_PRODUCTS_DIR; }; 30 | 2772A8B5230CA2140017442F /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 31 | 2772A8B7230CA2140017442F /* SceneDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SceneDelegate.swift; sourceTree = ""; }; 32 | 2772A8B9230CA2140017442F /* CatalogViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CatalogViewController.swift; sourceTree = ""; }; 33 | 2772A8BE230CA2150017442F /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 34 | 2772A8C1230CA2150017442F /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 35 | 2772A8C3230CA2150017442F /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 36 | 2772A8CE230CA3700017442F /* SingleViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SingleViewController.swift; sourceTree = ""; }; 37 | 2772A8D0230CA7970017442F /* ContextMenuDemo.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContextMenuDemo.swift; sourceTree = ""; }; 38 | 2772A8D2230CA8E60017442F /* CollectionViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CollectionViewController.swift; sourceTree = ""; }; 39 | 2773BA32230DB99300D08658 /* VCPreviewCollectionViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = VCPreviewCollectionViewController.swift; sourceTree = ""; }; 40 | 2773BA34230DBB2B00D08658 /* Fixtures.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Fixtures.swift; sourceTree = ""; }; 41 | 2773BA36230DBC2E00D08658 /* VCTargetedPreviewViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = VCTargetedPreviewViewController.swift; sourceTree = ""; }; 42 | 27C8E10B230CF4550047E4EB /* VCPreviewSingleViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = VCPreviewSingleViewController.swift; sourceTree = ""; }; 43 | 27D091F8230CE7D800C5B2FF /* TableViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TableViewController.swift; sourceTree = ""; }; 44 | 27D091FC230CEAC100C5B2FF /* SubmenuViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SubmenuViewController.swift; sourceTree = ""; }; 45 | 27D091FE230CEB9600C5B2FF /* InlineSubmenuViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = InlineSubmenuViewController.swift; sourceTree = ""; }; 46 | 27D09200230CEC5D00C5B2FF /* TargetedPreviewViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TargetedPreviewViewController.swift; sourceTree = ""; }; 47 | /* End PBXFileReference section */ 48 | 49 | /* Begin PBXFrameworksBuildPhase section */ 50 | 2772A8AF230CA2140017442F /* Frameworks */ = { 51 | isa = PBXFrameworksBuildPhase; 52 | buildActionMask = 2147483647; 53 | files = ( 54 | ); 55 | runOnlyForDeploymentPostprocessing = 0; 56 | }; 57 | /* End PBXFrameworksBuildPhase section */ 58 | 59 | /* Begin PBXGroup section */ 60 | 2772A8A9230CA2140017442F = { 61 | isa = PBXGroup; 62 | children = ( 63 | 2772A8B4230CA2140017442F /* ContextMenu */, 64 | 2772A8B3230CA2140017442F /* Products */, 65 | ); 66 | sourceTree = ""; 67 | }; 68 | 2772A8B3230CA2140017442F /* Products */ = { 69 | isa = PBXGroup; 70 | children = ( 71 | 2772A8B2230CA2140017442F /* ContextMenu.app */, 72 | ); 73 | name = Products; 74 | sourceTree = ""; 75 | }; 76 | 2772A8B4230CA2140017442F /* ContextMenu */ = { 77 | isa = PBXGroup; 78 | children = ( 79 | 2772A8C9230CA2DA0017442F /* Application */, 80 | 2772A8CA230CA2E40017442F /* Context Menu Demo */, 81 | 2772A8CB230CA2EF0017442F /* Assets */, 82 | ); 83 | path = ContextMenu; 84 | sourceTree = ""; 85 | }; 86 | 2772A8C9230CA2DA0017442F /* Application */ = { 87 | isa = PBXGroup; 88 | children = ( 89 | 2772A8B5230CA2140017442F /* AppDelegate.swift */, 90 | 2772A8B7230CA2140017442F /* SceneDelegate.swift */, 91 | ); 92 | path = Application; 93 | sourceTree = ""; 94 | }; 95 | 2772A8CA230CA2E40017442F /* Context Menu Demo */ = { 96 | isa = PBXGroup; 97 | children = ( 98 | 2773BA34230DBB2B00D08658 /* Fixtures.swift */, 99 | 2772A8D0230CA7970017442F /* ContextMenuDemo.swift */, 100 | 2772A8B9230CA2140017442F /* CatalogViewController.swift */, 101 | 27D091FA230CEA4100C5B2FF /* Basic Menus */, 102 | 27D091FB230CEAA000C5B2FF /* More Features */, 103 | ); 104 | path = "Context Menu Demo"; 105 | sourceTree = ""; 106 | }; 107 | 2772A8CB230CA2EF0017442F /* Assets */ = { 108 | isa = PBXGroup; 109 | children = ( 110 | 2772A8BE230CA2150017442F /* Assets.xcassets */, 111 | 2772A8C0230CA2150017442F /* LaunchScreen.storyboard */, 112 | 2772A8C3230CA2150017442F /* Info.plist */, 113 | ); 114 | path = Assets; 115 | sourceTree = ""; 116 | }; 117 | 27D091FA230CEA4100C5B2FF /* Basic Menus */ = { 118 | isa = PBXGroup; 119 | children = ( 120 | 2772A8CE230CA3700017442F /* SingleViewController.swift */, 121 | 27D091F8230CE7D800C5B2FF /* TableViewController.swift */, 122 | 2772A8D2230CA8E60017442F /* CollectionViewController.swift */, 123 | ); 124 | path = "Basic Menus"; 125 | sourceTree = ""; 126 | }; 127 | 27D091FB230CEAA000C5B2FF /* More Features */ = { 128 | isa = PBXGroup; 129 | children = ( 130 | 27D09202230CEC6600C5B2FF /* Submenus */, 131 | 27D09203230CEC8700C5B2FF /* Custom Previews */, 132 | ); 133 | path = "More Features"; 134 | sourceTree = ""; 135 | }; 136 | 27D09202230CEC6600C5B2FF /* Submenus */ = { 137 | isa = PBXGroup; 138 | children = ( 139 | 27D091FC230CEAC100C5B2FF /* SubmenuViewController.swift */, 140 | 27D091FE230CEB9600C5B2FF /* InlineSubmenuViewController.swift */, 141 | ); 142 | path = Submenus; 143 | sourceTree = ""; 144 | }; 145 | 27D09203230CEC8700C5B2FF /* Custom Previews */ = { 146 | isa = PBXGroup; 147 | children = ( 148 | 27C8E10B230CF4550047E4EB /* VCPreviewSingleViewController.swift */, 149 | 2773BA32230DB99300D08658 /* VCPreviewCollectionViewController.swift */, 150 | 27D09200230CEC5D00C5B2FF /* TargetedPreviewViewController.swift */, 151 | 2773BA36230DBC2E00D08658 /* VCTargetedPreviewViewController.swift */, 152 | ); 153 | path = "Custom Previews"; 154 | sourceTree = ""; 155 | }; 156 | /* End PBXGroup section */ 157 | 158 | /* Begin PBXNativeTarget section */ 159 | 2772A8B1230CA2140017442F /* ContextMenu */ = { 160 | isa = PBXNativeTarget; 161 | buildConfigurationList = 2772A8C6230CA2150017442F /* Build configuration list for PBXNativeTarget "ContextMenu" */; 162 | buildPhases = ( 163 | 2772A8AE230CA2140017442F /* Sources */, 164 | 2772A8AF230CA2140017442F /* Frameworks */, 165 | 2772A8B0230CA2140017442F /* Resources */, 166 | ); 167 | buildRules = ( 168 | ); 169 | dependencies = ( 170 | ); 171 | name = ContextMenu; 172 | productName = ContextMenu; 173 | productReference = 2772A8B2230CA2140017442F /* ContextMenu.app */; 174 | productType = "com.apple.product-type.application"; 175 | }; 176 | /* End PBXNativeTarget section */ 177 | 178 | /* Begin PBXProject section */ 179 | 2772A8AA230CA2140017442F /* Project object */ = { 180 | isa = PBXProject; 181 | attributes = { 182 | LastSwiftUpdateCheck = 1100; 183 | LastUpgradeCheck = 1100; 184 | ORGANIZATIONNAME = "Kyle Bashour"; 185 | TargetAttributes = { 186 | 2772A8B1230CA2140017442F = { 187 | CreatedOnToolsVersion = 11.0; 188 | }; 189 | }; 190 | }; 191 | buildConfigurationList = 2772A8AD230CA2140017442F /* Build configuration list for PBXProject "ContextMenu" */; 192 | compatibilityVersion = "Xcode 9.3"; 193 | developmentRegion = en; 194 | hasScannedForEncodings = 0; 195 | knownRegions = ( 196 | en, 197 | Base, 198 | ); 199 | mainGroup = 2772A8A9230CA2140017442F; 200 | productRefGroup = 2772A8B3230CA2140017442F /* Products */; 201 | projectDirPath = ""; 202 | projectRoot = ""; 203 | targets = ( 204 | 2772A8B1230CA2140017442F /* ContextMenu */, 205 | ); 206 | }; 207 | /* End PBXProject section */ 208 | 209 | /* Begin PBXResourcesBuildPhase section */ 210 | 2772A8B0230CA2140017442F /* Resources */ = { 211 | isa = PBXResourcesBuildPhase; 212 | buildActionMask = 2147483647; 213 | files = ( 214 | 2772A8C2230CA2150017442F /* LaunchScreen.storyboard in Resources */, 215 | 2772A8BF230CA2150017442F /* Assets.xcassets in Resources */, 216 | ); 217 | runOnlyForDeploymentPostprocessing = 0; 218 | }; 219 | /* End PBXResourcesBuildPhase section */ 220 | 221 | /* Begin PBXSourcesBuildPhase section */ 222 | 2772A8AE230CA2140017442F /* Sources */ = { 223 | isa = PBXSourcesBuildPhase; 224 | buildActionMask = 2147483647; 225 | files = ( 226 | 2772A8D3230CA8E60017442F /* CollectionViewController.swift in Sources */, 227 | 27C8E10C230CF4550047E4EB /* VCPreviewSingleViewController.swift in Sources */, 228 | 27D09201230CEC5D00C5B2FF /* TargetedPreviewViewController.swift in Sources */, 229 | 27D091F9230CE7D800C5B2FF /* TableViewController.swift in Sources */, 230 | 2772A8D1230CA7970017442F /* ContextMenuDemo.swift in Sources */, 231 | 2773BA35230DBB2B00D08658 /* Fixtures.swift in Sources */, 232 | 2772A8BA230CA2140017442F /* CatalogViewController.swift in Sources */, 233 | 2773BA37230DBC2E00D08658 /* VCTargetedPreviewViewController.swift in Sources */, 234 | 27D091FD230CEAC100C5B2FF /* SubmenuViewController.swift in Sources */, 235 | 2773BA33230DB99300D08658 /* VCPreviewCollectionViewController.swift in Sources */, 236 | 27D091FF230CEB9600C5B2FF /* InlineSubmenuViewController.swift in Sources */, 237 | 2772A8B6230CA2140017442F /* AppDelegate.swift in Sources */, 238 | 2772A8B8230CA2140017442F /* SceneDelegate.swift in Sources */, 239 | 2772A8CF230CA3700017442F /* SingleViewController.swift in Sources */, 240 | ); 241 | runOnlyForDeploymentPostprocessing = 0; 242 | }; 243 | /* End PBXSourcesBuildPhase section */ 244 | 245 | /* Begin PBXVariantGroup section */ 246 | 2772A8C0230CA2150017442F /* LaunchScreen.storyboard */ = { 247 | isa = PBXVariantGroup; 248 | children = ( 249 | 2772A8C1230CA2150017442F /* Base */, 250 | ); 251 | name = LaunchScreen.storyboard; 252 | sourceTree = ""; 253 | }; 254 | /* End PBXVariantGroup section */ 255 | 256 | /* Begin XCBuildConfiguration section */ 257 | 2772A8C4230CA2150017442F /* Debug */ = { 258 | isa = XCBuildConfiguration; 259 | buildSettings = { 260 | ALWAYS_SEARCH_USER_PATHS = NO; 261 | CLANG_ANALYZER_NONNULL = YES; 262 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 263 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; 264 | CLANG_CXX_LIBRARY = "libc++"; 265 | CLANG_ENABLE_MODULES = YES; 266 | CLANG_ENABLE_OBJC_ARC = YES; 267 | CLANG_ENABLE_OBJC_WEAK = YES; 268 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 269 | CLANG_WARN_BOOL_CONVERSION = YES; 270 | CLANG_WARN_COMMA = YES; 271 | CLANG_WARN_CONSTANT_CONVERSION = YES; 272 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 273 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 274 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 275 | CLANG_WARN_EMPTY_BODY = YES; 276 | CLANG_WARN_ENUM_CONVERSION = YES; 277 | CLANG_WARN_INFINITE_RECURSION = YES; 278 | CLANG_WARN_INT_CONVERSION = YES; 279 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 280 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 281 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 282 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 283 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 284 | CLANG_WARN_STRICT_PROTOTYPES = YES; 285 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 286 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; 287 | CLANG_WARN_UNREACHABLE_CODE = YES; 288 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 289 | COPY_PHASE_STRIP = NO; 290 | DEBUG_INFORMATION_FORMAT = dwarf; 291 | ENABLE_STRICT_OBJC_MSGSEND = YES; 292 | ENABLE_TESTABILITY = YES; 293 | GCC_C_LANGUAGE_STANDARD = gnu11; 294 | GCC_DYNAMIC_NO_PIC = NO; 295 | GCC_NO_COMMON_BLOCKS = YES; 296 | GCC_OPTIMIZATION_LEVEL = 0; 297 | GCC_PREPROCESSOR_DEFINITIONS = ( 298 | "DEBUG=1", 299 | "$(inherited)", 300 | ); 301 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 302 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 303 | GCC_WARN_UNDECLARED_SELECTOR = YES; 304 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 305 | GCC_WARN_UNUSED_FUNCTION = YES; 306 | GCC_WARN_UNUSED_VARIABLE = YES; 307 | IPHONEOS_DEPLOYMENT_TARGET = 13.0; 308 | MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; 309 | MTL_FAST_MATH = YES; 310 | ONLY_ACTIVE_ARCH = YES; 311 | SDKROOT = iphoneos; 312 | SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; 313 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 314 | }; 315 | name = Debug; 316 | }; 317 | 2772A8C5230CA2150017442F /* Release */ = { 318 | isa = XCBuildConfiguration; 319 | buildSettings = { 320 | ALWAYS_SEARCH_USER_PATHS = NO; 321 | CLANG_ANALYZER_NONNULL = YES; 322 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 323 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; 324 | CLANG_CXX_LIBRARY = "libc++"; 325 | CLANG_ENABLE_MODULES = YES; 326 | CLANG_ENABLE_OBJC_ARC = YES; 327 | CLANG_ENABLE_OBJC_WEAK = YES; 328 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 329 | CLANG_WARN_BOOL_CONVERSION = YES; 330 | CLANG_WARN_COMMA = YES; 331 | CLANG_WARN_CONSTANT_CONVERSION = YES; 332 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 333 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 334 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 335 | CLANG_WARN_EMPTY_BODY = YES; 336 | CLANG_WARN_ENUM_CONVERSION = YES; 337 | CLANG_WARN_INFINITE_RECURSION = YES; 338 | CLANG_WARN_INT_CONVERSION = YES; 339 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 340 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 341 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 342 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 343 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 344 | CLANG_WARN_STRICT_PROTOTYPES = YES; 345 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 346 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; 347 | CLANG_WARN_UNREACHABLE_CODE = YES; 348 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 349 | COPY_PHASE_STRIP = NO; 350 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 351 | ENABLE_NS_ASSERTIONS = NO; 352 | ENABLE_STRICT_OBJC_MSGSEND = YES; 353 | GCC_C_LANGUAGE_STANDARD = gnu11; 354 | GCC_NO_COMMON_BLOCKS = YES; 355 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 356 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 357 | GCC_WARN_UNDECLARED_SELECTOR = YES; 358 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 359 | GCC_WARN_UNUSED_FUNCTION = YES; 360 | GCC_WARN_UNUSED_VARIABLE = YES; 361 | IPHONEOS_DEPLOYMENT_TARGET = 13.0; 362 | MTL_ENABLE_DEBUG_INFO = NO; 363 | MTL_FAST_MATH = YES; 364 | SDKROOT = iphoneos; 365 | SWIFT_COMPILATION_MODE = wholemodule; 366 | SWIFT_OPTIMIZATION_LEVEL = "-O"; 367 | VALIDATE_PRODUCT = YES; 368 | }; 369 | name = Release; 370 | }; 371 | 2772A8C7230CA2150017442F /* Debug */ = { 372 | isa = XCBuildConfiguration; 373 | buildSettings = { 374 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 375 | CODE_SIGN_STYLE = Automatic; 376 | DEVELOPMENT_TEAM = ZEAD23GG77; 377 | INFOPLIST_FILE = ContextMenu/Assets/Info.plist; 378 | LD_RUNPATH_SEARCH_PATHS = ( 379 | "$(inherited)", 380 | "@executable_path/Frameworks", 381 | ); 382 | PRODUCT_BUNDLE_IDENTIFIER = com.kylebashour.ContextMenu; 383 | PRODUCT_NAME = "$(TARGET_NAME)"; 384 | SWIFT_VERSION = 5.0; 385 | TARGETED_DEVICE_FAMILY = "1,2"; 386 | }; 387 | name = Debug; 388 | }; 389 | 2772A8C8230CA2150017442F /* Release */ = { 390 | isa = XCBuildConfiguration; 391 | buildSettings = { 392 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 393 | CODE_SIGN_STYLE = Automatic; 394 | DEVELOPMENT_TEAM = ZEAD23GG77; 395 | INFOPLIST_FILE = ContextMenu/Assets/Info.plist; 396 | LD_RUNPATH_SEARCH_PATHS = ( 397 | "$(inherited)", 398 | "@executable_path/Frameworks", 399 | ); 400 | PRODUCT_BUNDLE_IDENTIFIER = com.kylebashour.ContextMenu; 401 | PRODUCT_NAME = "$(TARGET_NAME)"; 402 | SWIFT_VERSION = 5.0; 403 | TARGETED_DEVICE_FAMILY = "1,2"; 404 | }; 405 | name = Release; 406 | }; 407 | /* End XCBuildConfiguration section */ 408 | 409 | /* Begin XCConfigurationList section */ 410 | 2772A8AD230CA2140017442F /* Build configuration list for PBXProject "ContextMenu" */ = { 411 | isa = XCConfigurationList; 412 | buildConfigurations = ( 413 | 2772A8C4230CA2150017442F /* Debug */, 414 | 2772A8C5230CA2150017442F /* Release */, 415 | ); 416 | defaultConfigurationIsVisible = 0; 417 | defaultConfigurationName = Release; 418 | }; 419 | 2772A8C6230CA2150017442F /* Build configuration list for PBXNativeTarget "ContextMenu" */ = { 420 | isa = XCConfigurationList; 421 | buildConfigurations = ( 422 | 2772A8C7230CA2150017442F /* Debug */, 423 | 2772A8C8230CA2150017442F /* Release */, 424 | ); 425 | defaultConfigurationIsVisible = 0; 426 | defaultConfigurationName = Release; 427 | }; 428 | /* End XCConfigurationList section */ 429 | }; 430 | rootObject = 2772A8AA230CA2140017442F /* Project object */; 431 | } 432 | -------------------------------------------------------------------------------- /ContextMenu.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /ContextMenu.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /ContextMenu/Application/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.swift 3 | // ContextMenu 4 | // 5 | // Created by Kyle Bashour on 8/20/19. 6 | // Copyright © 2019 Kyle Bashour. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | @UIApplicationMain 12 | class AppDelegate: UIResponder, UIApplicationDelegate { 13 | 14 | func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { 15 | return true 16 | } 17 | 18 | func application(_ application: UIApplication, configurationForConnecting connectingSceneSession: UISceneSession, options: UIScene.ConnectionOptions) -> UISceneConfiguration { 19 | // Called when a new scene session is being created. 20 | // Use this method to select a configuration to create the new scene with. 21 | return UISceneConfiguration(name: "Default Configuration", sessionRole: connectingSceneSession.role) 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /ContextMenu/Application/SceneDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // SceneDelegate.swift 3 | // ContextMenu 4 | // 5 | // Created by Kyle Bashour on 8/20/19. 6 | // Copyright © 2019 Kyle Bashour. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | class SceneDelegate: UIResponder, UIWindowSceneDelegate { 12 | 13 | var window: UIWindow? 14 | 15 | func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) { 16 | guard let scene = scene as? UIWindowScene else { return } 17 | 18 | let navigationController = UINavigationController(rootViewController: CatalogViewController(style: .insetGrouped)) 19 | 20 | window = UIWindow(windowScene: scene) 21 | window?.rootViewController = navigationController 22 | window?.makeKeyAndVisible() 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /ContextMenu/Assets/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "20x20", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "20x20", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "29x29", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "29x29", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "40x40", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "40x40", 31 | "scale" : "3x" 32 | }, 33 | { 34 | "idiom" : "iphone", 35 | "size" : "60x60", 36 | "scale" : "2x" 37 | }, 38 | { 39 | "idiom" : "iphone", 40 | "size" : "60x60", 41 | "scale" : "3x" 42 | }, 43 | { 44 | "idiom" : "ipad", 45 | "size" : "20x20", 46 | "scale" : "1x" 47 | }, 48 | { 49 | "idiom" : "ipad", 50 | "size" : "20x20", 51 | "scale" : "2x" 52 | }, 53 | { 54 | "idiom" : "ipad", 55 | "size" : "29x29", 56 | "scale" : "1x" 57 | }, 58 | { 59 | "idiom" : "ipad", 60 | "size" : "29x29", 61 | "scale" : "2x" 62 | }, 63 | { 64 | "idiom" : "ipad", 65 | "size" : "40x40", 66 | "scale" : "1x" 67 | }, 68 | { 69 | "idiom" : "ipad", 70 | "size" : "40x40", 71 | "scale" : "2x" 72 | }, 73 | { 74 | "idiom" : "ipad", 75 | "size" : "76x76", 76 | "scale" : "1x" 77 | }, 78 | { 79 | "idiom" : "ipad", 80 | "size" : "76x76", 81 | "scale" : "2x" 82 | }, 83 | { 84 | "idiom" : "ipad", 85 | "size" : "83.5x83.5", 86 | "scale" : "2x" 87 | }, 88 | { 89 | "idiom" : "ios-marketing", 90 | "size" : "1024x1024", 91 | "scale" : "1x" 92 | } 93 | ], 94 | "info" : { 95 | "version" : 1, 96 | "author" : "xcode" 97 | } 98 | } -------------------------------------------------------------------------------- /ContextMenu/Assets/Assets.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "version" : 1, 4 | "author" : "xcode" 5 | } 6 | } -------------------------------------------------------------------------------- /ContextMenu/Assets/Assets.xcassets/images/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "version" : 1, 4 | "author" : "xcode" 5 | } 6 | } -------------------------------------------------------------------------------- /ContextMenu/Assets/Assets.xcassets/images/bridge.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "bridge.jpeg" 6 | } 7 | ], 8 | "info" : { 9 | "version" : 1, 10 | "author" : "xcode" 11 | } 12 | } -------------------------------------------------------------------------------- /ContextMenu/Assets/Assets.xcassets/images/bridge.imageset/bridge.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kylebshr/context-menus/88844a321c8a90e4882856cdec286b626ef10efc/ContextMenu/Assets/Assets.xcassets/images/bridge.imageset/bridge.jpeg -------------------------------------------------------------------------------- /ContextMenu/Assets/Assets.xcassets/images/flowers.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "flowers.jpeg" 6 | } 7 | ], 8 | "info" : { 9 | "version" : 1, 10 | "author" : "xcode" 11 | } 12 | } -------------------------------------------------------------------------------- /ContextMenu/Assets/Assets.xcassets/images/flowers.imageset/flowers.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kylebshr/context-menus/88844a321c8a90e4882856cdec286b626ef10efc/ContextMenu/Assets/Assets.xcassets/images/flowers.imageset/flowers.jpeg -------------------------------------------------------------------------------- /ContextMenu/Assets/Assets.xcassets/images/mountains.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "mountains.jpeg" 6 | } 7 | ], 8 | "info" : { 9 | "version" : 1, 10 | "author" : "xcode" 11 | } 12 | } -------------------------------------------------------------------------------- /ContextMenu/Assets/Assets.xcassets/images/mountains.imageset/mountains.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kylebshr/context-menus/88844a321c8a90e4882856cdec286b626ef10efc/ContextMenu/Assets/Assets.xcassets/images/mountains.imageset/mountains.jpeg -------------------------------------------------------------------------------- /ContextMenu/Assets/Assets.xcassets/images/rock.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "rock.jpeg" 6 | } 7 | ], 8 | "info" : { 9 | "version" : 1, 10 | "author" : "xcode" 11 | } 12 | } -------------------------------------------------------------------------------- /ContextMenu/Assets/Assets.xcassets/images/rock.imageset/rock.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kylebshr/context-menus/88844a321c8a90e4882856cdec286b626ef10efc/ContextMenu/Assets/Assets.xcassets/images/rock.imageset/rock.jpeg -------------------------------------------------------------------------------- /ContextMenu/Assets/Assets.xcassets/images/skis.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "skis.jpeg" 6 | } 7 | ], 8 | "info" : { 9 | "version" : 1, 10 | "author" : "xcode" 11 | } 12 | } -------------------------------------------------------------------------------- /ContextMenu/Assets/Assets.xcassets/images/skis.imageset/skis.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kylebshr/context-menus/88844a321c8a90e4882856cdec286b626ef10efc/ContextMenu/Assets/Assets.xcassets/images/skis.imageset/skis.jpeg -------------------------------------------------------------------------------- /ContextMenu/Assets/Assets.xcassets/images/street.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "street.jpeg" 6 | } 7 | ], 8 | "info" : { 9 | "version" : 1, 10 | "author" : "xcode" 11 | } 12 | } -------------------------------------------------------------------------------- /ContextMenu/Assets/Assets.xcassets/images/street.imageset/street.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kylebshr/context-menus/88844a321c8a90e4882856cdec286b626ef10efc/ContextMenu/Assets/Assets.xcassets/images/street.imageset/street.jpeg -------------------------------------------------------------------------------- /ContextMenu/Assets/Assets.xcassets/images/sunset.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "sunset.jpeg" 6 | } 7 | ], 8 | "info" : { 9 | "version" : 1, 10 | "author" : "xcode" 11 | } 12 | } -------------------------------------------------------------------------------- /ContextMenu/Assets/Assets.xcassets/images/sunset.imageset/sunset.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kylebshr/context-menus/88844a321c8a90e4882856cdec286b626ef10efc/ContextMenu/Assets/Assets.xcassets/images/sunset.imageset/sunset.jpeg -------------------------------------------------------------------------------- /ContextMenu/Assets/Base.lproj/LaunchScreen.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /ContextMenu/Assets/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | $(PRODUCT_BUNDLE_PACKAGE_TYPE) 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | 1 21 | LSRequiresIPhoneOS 22 | 23 | UIApplicationSceneManifest 24 | 25 | UIApplicationSupportsMultipleScenes 26 | 27 | UISceneConfigurations 28 | 29 | UIWindowSceneSessionRoleApplication 30 | 31 | 32 | UISceneConfigurationName 33 | Default Configuration 34 | UISceneDelegateClassName 35 | $(PRODUCT_MODULE_NAME).SceneDelegate 36 | 37 | 38 | 39 | 40 | UILaunchStoryboardName 41 | LaunchScreen 42 | UIRequiredDeviceCapabilities 43 | 44 | armv7 45 | 46 | UISupportedInterfaceOrientations 47 | 48 | UIInterfaceOrientationPortrait 49 | UIInterfaceOrientationLandscapeRight 50 | UIInterfaceOrientationLandscapeLeft 51 | 52 | UISupportedInterfaceOrientations~ipad 53 | 54 | UIInterfaceOrientationPortrait 55 | UIInterfaceOrientationPortraitUpsideDown 56 | UIInterfaceOrientationLandscapeLeft 57 | UIInterfaceOrientationLandscapeRight 58 | 59 | 60 | 61 | -------------------------------------------------------------------------------- /ContextMenu/Context Menu Demo/Basic Menus/CollectionViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // CollectionViewController.swift 3 | // ContextMenu 4 | // 5 | // Created by Kyle Bashour on 8/20/19. 6 | // Copyright © 2019 Kyle Bashour. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | /* 12 | 13 | This view controller displays a collection view. Long-pressing on an item will open a context menu for that item. 14 | 15 | */ 16 | 17 | class CollectionViewController: UICollectionViewController, ContextMenuDemo { 18 | 19 | // MARK: ContextMenuDemo 20 | 21 | static var title: String { return "Collection View" } 22 | 23 | // MARK: CollectionViewController 24 | 25 | private let identifier = "cell" 26 | 27 | init() { 28 | super.init(collectionViewLayout: Self.makeCollectionViewLayout()) 29 | } 30 | 31 | @available(*, unavailable) 32 | required init?(coder: NSCoder) { 33 | fatalError("init(coder:) has not been implemented") 34 | } 35 | 36 | override func viewDidLoad() { 37 | super.viewDidLoad() 38 | 39 | navigationItem.title = Self.title 40 | 41 | collectionView.register(UICollectionViewCell.self, forCellWithReuseIdentifier: identifier) 42 | collectionView.backgroundColor = .systemBackground 43 | collectionView.dataSource = self 44 | collectionView.delegate = self 45 | } 46 | 47 | private static func makeCollectionViewLayout() -> UICollectionViewLayout { 48 | let itemSize = NSCollectionLayoutSize(widthDimension: .fractionalWidth(1.0 / 3), heightDimension: .fractionalHeight(1)) 49 | let item = NSCollectionLayoutItem(layoutSize: itemSize) 50 | 51 | let groupSize = NSCollectionLayoutSize(widthDimension: .fractionalWidth(1), heightDimension: .fractionalWidth(1.0 / 3)) 52 | let group = NSCollectionLayoutGroup.horizontal(layoutSize: groupSize, subitem: item, count: 3) 53 | group.interItemSpacing = .fixed(1) 54 | 55 | let section = NSCollectionLayoutSection(group: group) 56 | section.interGroupSpacing = 1 57 | 58 | return UICollectionViewCompositionalLayout(section: section) 59 | } 60 | 61 | // MARK: - UICollectionViewDelegate 62 | 63 | /* 64 | 65 | In a collection view, there's no need to register an interaction - 66 | this delegate method is where you create and return a menu. 67 | 68 | */ 69 | 70 | override func collectionView(_ collectionView: UICollectionView, contextMenuConfigurationForItemAt indexPath: IndexPath, point: CGPoint) -> UIContextMenuConfiguration? { 71 | return UIContextMenuConfiguration(identifier: nil, previewProvider: nil) { suggestedActions in 72 | return self.makeDefaultDemoMenu() 73 | } 74 | } 75 | 76 | // MARK: - UICollectionViewDataSource 77 | 78 | override func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int { 79 | return Fixtures.colors.count 80 | } 81 | 82 | override func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell { 83 | let cell = collectionView.dequeueReusableCell(withReuseIdentifier: identifier, for: indexPath) 84 | cell.contentView.backgroundColor = Fixtures.colors[indexPath.row] 85 | cell.backgroundColor = Fixtures.colors[indexPath.row] 86 | return cell 87 | } 88 | } 89 | -------------------------------------------------------------------------------- /ContextMenu/Context Menu Demo/Basic Menus/SingleViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // SingleViewController.swift 3 | // ContextMenu 4 | // 5 | // Created by Kyle Bashour on 8/20/19. 6 | // Copyright © 2019 Kyle Bashour. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | /* 12 | 13 | This view controller displays a square. Long-pressing the square will open a context menu for that view. 14 | 15 | */ 16 | 17 | class SingleViewController: UIViewController, ContextMenuDemo { 18 | 19 | // MARK: ContextMenuDemo 20 | 21 | static var title: String { return "Single View" } 22 | 23 | // MARK: SingleViewController 24 | 25 | private let menuView = UIView() 26 | 27 | override func viewDidLoad() { 28 | super.viewDidLoad() 29 | 30 | navigationItem.title = Self.title 31 | view.backgroundColor = .systemBackground 32 | 33 | menuView.backgroundColor = .systemBlue 34 | menuView.frame.size = .init(width: 100, height: 100) 35 | view.addSubview(menuView) 36 | 37 | /* 38 | 39 | Here we create an interaction, give it a delegate, and 40 | add it to a view. This tells UIKit to call the delegate 41 | methods when the view is long-press or 3D touched, and 42 | display a menu if the delegate returns one. 43 | 44 | */ 45 | 46 | let interaction = UIContextMenuInteraction(delegate: self) 47 | menuView.addInteraction(interaction) 48 | } 49 | 50 | override func viewDidLayoutSubviews() { 51 | super.viewDidLayoutSubviews() 52 | menuView.center = view.center 53 | } 54 | } 55 | 56 | extension SingleViewController: UIContextMenuInteractionDelegate { 57 | 58 | /* 59 | 60 | This is where you create and return a menu. This demo 61 | just uses a simple menu with three actions - check out 62 | `makeDefaultDemoMenu` to see how it's created. 63 | 64 | */ 65 | 66 | func contextMenuInteraction(_ interaction: UIContextMenuInteraction, configurationForMenuAtLocation location: CGPoint) -> UIContextMenuConfiguration? { 67 | return UIContextMenuConfiguration(identifier: nil, previewProvider: nil) { suggestedActions in 68 | return self.makeDefaultDemoMenu() 69 | } 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /ContextMenu/Context Menu Demo/Basic Menus/TableViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // TableViewController.swift 3 | // ContextMenu 4 | // 5 | // Created by Kyle Bashour on 8/20/19. 6 | // Copyright © 2019 Kyle Bashour. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | /* 12 | 13 | This view controller displays a table view. Long-pressing on a row will open a context menu for that item. 14 | 15 | */ 16 | 17 | class TableViewController: UITableViewController, ContextMenuDemo { 18 | 19 | // MARK: ContextMenuDemo 20 | 21 | static var title: String { return "Table View" } 22 | 23 | // MARK: TableViewController 24 | 25 | private let identifier = "identifier" 26 | 27 | override func viewDidLoad() { 28 | super.viewDidLoad() 29 | 30 | navigationItem.title = Self.title 31 | tableView.allowsSelection = false 32 | tableView.register(UITableViewCell.self, forCellReuseIdentifier: identifier) 33 | } 34 | 35 | // MARK: - UITableViewDelegate 36 | 37 | /* 38 | 39 | In a table view, there's no need to register an interaction - 40 | this delegate method is where you create and return a menu. 41 | 42 | */ 43 | 44 | override func tableView(_ tableView: UITableView, contextMenuConfigurationForRowAt indexPath: IndexPath, point: CGPoint) -> UIContextMenuConfiguration? { 45 | return UIContextMenuConfiguration(identifier: nil, previewProvider: nil) { suggestedActions in 46 | return self.makeDefaultDemoMenu() 47 | } 48 | } 49 | 50 | // MARK: - UITableViewDataSource 51 | 52 | override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { 53 | return Fixtures.lorem.count 54 | } 55 | 56 | override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { 57 | let cell = tableView.dequeueReusableCell(withIdentifier: identifier, for: indexPath) 58 | cell.textLabel?.text = Fixtures.lorem[indexPath.row] 59 | return cell 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /ContextMenu/Context Menu Demo/CatalogViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // CatalogViewController.swift 3 | // ContextMenu 4 | // 5 | // Created by Kyle Bashour on 8/20/19. 6 | // Copyright © 2019 Kyle Bashour. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | class CatalogViewController: UITableViewController { 12 | private let identifier = "cell" 13 | 14 | typealias DemoViewController = ContextMenuDemo & UIViewController 15 | 16 | private let demos: [(title: String, viewControllers: [DemoViewController.Type])] = [ 17 | ("Basic Menus", [ 18 | SingleViewController.self, 19 | TableViewController.self, 20 | CollectionViewController.self, 21 | ]), 22 | ("Submenus", [ 23 | SubmenuViewController.self, 24 | InlineSubmenuViewController.self, 25 | ]), 26 | 27 | ("Custom Previews", [ 28 | VCPreviewSingleViewController.self, 29 | VCPreviewCollectionViewController.self, 30 | TargetedPreviewViewController.self, 31 | VCTargetedPreviewViewController.self, 32 | ]), 33 | ] 34 | 35 | override init(style: UITableView.Style) { 36 | super.init(style: style) 37 | 38 | navigationItem.title = "Context Menu Demos" 39 | tableView.register(UITableViewCell.self, forCellReuseIdentifier: identifier) 40 | } 41 | 42 | @available(*, unavailable) 43 | required init?(coder: NSCoder) { 44 | fatalError("init(coder:) has not been implemented") 45 | } 46 | 47 | override func numberOfSections(in tableView: UITableView) -> Int { 48 | return demos.count 49 | } 50 | 51 | override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { 52 | return demos[section].viewControllers.count 53 | } 54 | 55 | override func tableView(_ tableView: UITableView, titleForHeaderInSection section: Int) -> String? { 56 | return demos[section].title 57 | } 58 | 59 | override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { 60 | let cell = tableView.dequeueReusableCell(withIdentifier: identifier, for: indexPath) 61 | cell.textLabel?.text = demos[indexPath.section].viewControllers[indexPath.row].title 62 | cell.accessoryType = .disclosureIndicator 63 | return cell 64 | } 65 | 66 | override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { 67 | let viewController = demos[indexPath.section].viewControllers[indexPath.row].init() 68 | navigationController?.pushViewController(viewController, animated: true) 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /ContextMenu/Context Menu Demo/ContextMenuDemo.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ContextMenuDemo.swift 3 | // ContextMenu 4 | // 5 | // Created by Kyle Bashour on 8/20/19. 6 | // Copyright © 2019 Kyle Bashour. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | protocol ContextMenuDemo { 12 | static var title: String { get } 13 | } 14 | 15 | extension ContextMenuDemo { 16 | func makeDefaultDemoMenu() -> UIMenu { 17 | 18 | // Create a UIAction for sharing 19 | let share = UIAction(title: "Share", image: UIImage(systemName: "square.and.arrow.up")) { action in 20 | // Show system share sheet 21 | } 22 | 23 | // Create an action for renaming 24 | let rename = UIAction(title: "Rename", image: UIImage(systemName: "square.and.pencil")) { action in 25 | // Perform renaming 26 | } 27 | 28 | // Here we specify the "destructive" attribute to show that it’s destructive in nature 29 | let delete = UIAction(title: "Delete", image: UIImage(systemName: "trash"), attributes: .destructive) { action in 30 | // Perform delete 31 | } 32 | 33 | // Create and return a UIMenu with all of the actions as children 34 | return UIMenu(title: "", children: [share, rename, delete]) 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /ContextMenu/Context Menu Demo/Fixtures.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Fixtures.swift 3 | // ContextMenu 4 | // 5 | // Created by Kyle Bashour on 8/21/19. 6 | // Copyright © 2019 Kyle Bashour. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | enum Fixtures { 12 | static let lorem = [ 13 | "Lorem ipsum", 14 | "dolor sit", 15 | "amet consectetur", 16 | "adipiscing elit", 17 | "sed do", 18 | "eiusmod tempor", 19 | "incididunt ut", 20 | "labore et", 21 | "dolore magna", 22 | "aliqua Ut", 23 | "enim ad", 24 | "minim veniam", 25 | "quis nostrud", 26 | "exercitation ullamco", 27 | "laboris nisi", 28 | "ut aliquip", 29 | "ex ea", 30 | "commodo consequat", 31 | "Duis aute", 32 | "irure dolor", 33 | "in reprehenderit", 34 | "in voluptate", 35 | "velit esse", 36 | ] 37 | 38 | static let cloudSymbols = [ 39 | "cloud", 40 | "cloud.bolt", 41 | "cloud.bolt.fill", 42 | "cloud.bolt.rain", 43 | "cloud.bolt.rain.fill", 44 | "cloud.drizzle", 45 | "cloud.drizzle.fill", 46 | "cloud.fill", 47 | "cloud.fog", 48 | "cloud.fog.fill", 49 | "cloud.hail", 50 | "cloud.hail.fill", 51 | "cloud.heavyrain", 52 | "cloud.heavyrain.fill", 53 | "cloud.moon", 54 | "cloud.moon.bolt", 55 | "cloud.moon.bolt.fill", 56 | "cloud.moon.fill", 57 | "cloud.moon.rain", 58 | "cloud.moon.rain.fill", 59 | "cloud.rain", 60 | "cloud.rain.fill", 61 | "cloud.sleet", 62 | "cloud.sleet.fill", 63 | "cloud.snow", 64 | "cloud.snow.fill", 65 | "cloud.sun", 66 | "cloud.sun.bolt", 67 | "cloud.sun.bolt.fill", 68 | "cloud.sun.fill", 69 | "cloud.sun.rain", 70 | "cloud.sun.rain.fill", 71 | ] 72 | 73 | static let colors: [UIColor] = { 74 | return [ 75 | .systemRed, .systemRed, .systemRed, 76 | .systemBlue, .systemBlue, .systemBlue, 77 | .systemPink, .systemPink, .systemPink, 78 | .systemGreen, .systemGreen, .systemGreen, 79 | .systemPurple, .systemPurple, .systemPurple, 80 | .systemTeal, .systemTeal, .systemTeal, 81 | .systemOrange, .systemOrange, .systemOrange 82 | ].shuffled() 83 | }() 84 | 85 | static let images = [ 86 | "bridge", 87 | "flowers", 88 | "mountains", 89 | "rock", 90 | "skis", 91 | "street", 92 | "sunset", 93 | "bridge", 94 | "flowers", 95 | "mountains", 96 | "rock", 97 | "skis", 98 | "street", 99 | "sunset", 100 | "bridge", 101 | "flowers", 102 | "mountains", 103 | "rock", 104 | "skis", 105 | "street", 106 | "sunset", 107 | "bridge", 108 | "flowers", 109 | "mountains", 110 | "rock", 111 | "skis", 112 | "street", 113 | "sunset", 114 | ] 115 | } 116 | -------------------------------------------------------------------------------- /ContextMenu/Context Menu Demo/More Features/Custom Previews/TargetedPreviewViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // TargetedPreviewViewController.swift 3 | // ContextMenu 4 | // 5 | // Created by Kyle Bashour on 8/20/19. 6 | // Copyright © 2019 Kyle Bashour. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | /* 12 | 13 | This view controller displays a list of icons with their names, and has a custom preview of the icon when 14 | the menu is opened. The preview is a custom view, and has a custom shape applied instead of the default rounded rect. 15 | When the preview is tapped, it pushes a view controller that displays the icon. 16 | 17 | */ 18 | 19 | 20 | /// A UITableViewCell for displaying an SF Symbol and its name 21 | private class IconPreviewCell: UITableViewCell { 22 | let previewView = UIView() 23 | 24 | private let iconView = UIImageView() 25 | private let label = UILabel() 26 | 27 | override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) { 28 | super.init(style: style, reuseIdentifier: reuseIdentifier) 29 | 30 | iconView.tintColor = .white 31 | iconView.contentMode = .center 32 | iconView.translatesAutoresizingMaskIntoConstraints = false 33 | previewView.addSubview(iconView) 34 | 35 | previewView.tintColor = .white 36 | previewView.layer.cornerRadius = 20 37 | previewView.backgroundColor = .systemBlue 38 | previewView.translatesAutoresizingMaskIntoConstraints = false 39 | contentView.addSubview(previewView) 40 | 41 | label.textColor = .label 42 | label.font = UIFont.preferredFont(forTextStyle: .body) 43 | label.translatesAutoresizingMaskIntoConstraints = false 44 | contentView.addSubview(label) 45 | 46 | // Fix for a long-standing issue with cells breaking constraints 47 | let bottomAnchor = contentView.bottomAnchor.constraint(equalToSystemSpacingBelow: previewView.bottomAnchor, multiplier: 1) 48 | bottomAnchor.priority = .required - 1 49 | 50 | NSLayoutConstraint.activate([ 51 | iconView.centerXAnchor.constraint(equalTo: previewView.centerXAnchor), 52 | iconView.centerYAnchor.constraint(equalTo: previewView.centerYAnchor), 53 | 54 | previewView.heightAnchor.constraint(equalToConstant: 40), 55 | previewView.widthAnchor.constraint(equalToConstant: 40), 56 | previewView.topAnchor.constraint(equalToSystemSpacingBelow: contentView.topAnchor, multiplier: 1), 57 | previewView.leadingAnchor.constraint(equalToSystemSpacingAfter: contentView.leadingAnchor, multiplier: 1), 58 | bottomAnchor, 59 | 60 | label.centerYAnchor.constraint(equalTo: contentView.centerYAnchor), 61 | label.leadingAnchor.constraint(equalToSystemSpacingAfter: previewView.trailingAnchor, multiplier: 1), 62 | contentView.trailingAnchor.constraint(equalToSystemSpacingAfter: label.trailingAnchor, multiplier: 1), 63 | ]) 64 | } 65 | 66 | required init?(coder: NSCoder) { 67 | fatalError("init(coder:) has not been implemented") 68 | } 69 | 70 | func display(systemImageName: String) { 71 | label.text = systemImageName 72 | iconView.image = UIImage(systemName: systemImageName) 73 | } 74 | } 75 | 76 | /// A view controller for displaying a single icon 77 | private class IconPreviewViewController: UIViewController { 78 | private let imageView = UIImageView() 79 | 80 | init(systemImageName: String) { 81 | super.init(nibName: nil, bundle: nil) 82 | 83 | view.backgroundColor = .secondarySystemBackground 84 | navigationItem.title = systemImageName 85 | 86 | imageView.image = UIImage(systemName: systemImageName) 87 | imageView.tintColor = .systemBlue 88 | imageView.contentMode = .scaleAspectFit 89 | imageView.translatesAutoresizingMaskIntoConstraints = false 90 | view.addSubview(imageView) 91 | 92 | NSLayoutConstraint.activate([ 93 | imageView.widthAnchor.constraint(equalToConstant: 80), 94 | imageView.heightAnchor.constraint(equalToConstant: 80), 95 | imageView.centerXAnchor.constraint(equalTo: view.centerXAnchor), 96 | imageView.centerYAnchor.constraint(equalTo: view.centerYAnchor), 97 | ]) 98 | } 99 | 100 | required init?(coder: NSCoder) { 101 | fatalError("init(coder:) has not been implemented") 102 | } 103 | } 104 | 105 | class TargetedPreviewViewController: UITableViewController, ContextMenuDemo { 106 | 107 | // MARK: ContextMenuDemo 108 | 109 | static var title: String { return "UITargetedPreview" } 110 | 111 | // MARK: CustomPreviewTableViewController 112 | 113 | private let identifier = "identifier" 114 | 115 | override func viewDidLoad() { 116 | super.viewDidLoad() 117 | 118 | navigationItem.title = Self.title 119 | tableView.register(IconPreviewCell.self, forCellReuseIdentifier: identifier) 120 | } 121 | 122 | // Since we need to create the same preview for highlighting and dismissing, we'll put it in a utility method 123 | private func makeTargetedPreview(for configuration: UIContextMenuConfiguration) -> UITargetedPreview? { 124 | 125 | // Ensure we can get the expected identifier 126 | guard let identifier = configuration.identifier as? String else { return nil } 127 | 128 | // Get the current index of the identifier 129 | guard let row = Fixtures.cloudSymbols.firstIndex(of: identifier) else { return nil } 130 | 131 | // Get the cell for the index of the model 132 | guard let cell = tableView.cellForRow(at: .init(row: row, section: 0)) as? IconPreviewCell else { return nil } 133 | 134 | // Since our preview has its own shape (a circle) we need to set the preview parameters 135 | // backgroundColor to clear, or we'll see a white rect behind it. 136 | let parameters = UIPreviewParameters() 137 | parameters.backgroundColor = .clear 138 | 139 | // Return a targeted preview using our cell previewView and parameters 140 | return UITargetedPreview(view: cell.previewView, parameters: parameters) 141 | } 142 | 143 | // MARK: - UITableViewDataSource 144 | 145 | override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { 146 | return Fixtures.cloudSymbols.count 147 | } 148 | 149 | override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { 150 | let cell = tableView.dequeueReusableCell(withIdentifier: identifier, for: indexPath) as! IconPreviewCell 151 | cell.display(systemImageName: Fixtures.cloudSymbols[indexPath.row]) 152 | cell.accessoryType = .disclosureIndicator 153 | return cell 154 | } 155 | 156 | // MARK: - UITableViewDelegate 157 | 158 | /* 159 | 160 | When creating our configuration, we'll specify an 161 | identifier so that we can tell which item is being 162 | previewed in `previewForHighlightingContextMenuWithConfiguration` 163 | & `previewForDismissingContextMenuWithConfiguration`. 164 | Since they create their preview the same way, I've put 165 | the implementation into a helper method above. 166 | 167 | It's best not to pass the index path as your identifier, 168 | as the table view data could change while a menu is open. 169 | Passing the id of the model is a good idea. 170 | 171 | We'll also implement `willPerformPreviewActionForMenuWith` 172 | to respond to the user tapping on the preview. 173 | 174 | */ 175 | 176 | override func tableView(_ tableView: UITableView, contextMenuConfigurationForRowAt indexPath: IndexPath, point: CGPoint) -> UIContextMenuConfiguration? { 177 | 178 | // We have to create an NSString since the identifier must conform to NSCopying 179 | let identifier = NSString(string: Fixtures.cloudSymbols[indexPath.row]) 180 | 181 | // Create our configuration with an indentifier 182 | return UIContextMenuConfiguration(identifier: identifier, previewProvider: nil) { suggestedActions in 183 | return self.makeDefaultDemoMenu() 184 | } 185 | } 186 | 187 | override func tableView(_ tableView: UITableView, previewForHighlightingContextMenuWithConfiguration configuration: UIContextMenuConfiguration) -> UITargetedPreview? { 188 | return makeTargetedPreview(for: configuration) 189 | } 190 | 191 | override func tableView(_ tableView: UITableView, previewForDismissingContextMenuWithConfiguration configuration: UIContextMenuConfiguration) -> UITargetedPreview? { 192 | return makeTargetedPreview(for: configuration) 193 | } 194 | 195 | override func tableView(_ tableView: UITableView, willPerformPreviewActionForMenuWith configuration: UIContextMenuConfiguration, animator: UIContextMenuInteractionCommitAnimating) { 196 | 197 | animator.addCompletion { 198 | 199 | // Ensure we can get the expected identifier and create an image 200 | guard let identifier = configuration.identifier as? String else { return } 201 | 202 | // Create and push the appropiate view controller 203 | let viewController = IconPreviewViewController(systemImageName: identifier) 204 | self.show(viewController, sender: self) 205 | } 206 | } 207 | 208 | override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { 209 | let viewController = IconPreviewViewController(systemImageName: Fixtures.cloudSymbols[indexPath.row]) 210 | show(viewController, sender: self) 211 | } 212 | } 213 | -------------------------------------------------------------------------------- /ContextMenu/Context Menu Demo/More Features/Custom Previews/VCPreviewCollectionViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // VCPreviewTableViewController.swift 3 | // ContextMenu 4 | // 5 | // Created by Kyle Bashour on 8/20/19. 6 | // Copyright © 2019 Kyle Bashour. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | /* 12 | 13 | This view controller displays a list of icons with their names, and uses a view controller for the menu preview. 14 | When the preview is tapped, it pushes that view controller. 15 | 16 | */ 17 | 18 | /// A view controller used for previewing and when an item is selected 19 | private class PhotoPreviewViewController: UIViewController { 20 | private let imageName: String 21 | private let imageView = UIImageView() 22 | 23 | init(imageName: String) { 24 | self.imageName = imageName 25 | super.init(nibName: nil, bundle: nil) 26 | } 27 | 28 | required init?(coder: NSCoder) { 29 | fatalError("init(coder:) has not been implemented") 30 | } 31 | 32 | override func viewDidLoad() { 33 | super.viewDidLoad() 34 | 35 | navigationItem.title = imageName.capitalized 36 | let image = UIImage(named: imageName)! 37 | 38 | imageView.image = image 39 | imageView.clipsToBounds = true 40 | imageView.contentMode = .scaleAspectFill 41 | imageView.autoresizingMask = [.flexibleWidth, .flexibleHeight] 42 | imageView.frame = view.bounds 43 | view.addSubview(imageView) 44 | 45 | // The preview will size to the preferredContentSize, which can be useful 46 | // for displaying a preview with the dimension of an image, for example. 47 | // Unlike peek and pop, it doesn't automatically scale down for you. 48 | 49 | let width: CGFloat 50 | let height: CGFloat 51 | 52 | if image.size.width > image.size.height { 53 | width = view.frame.width 54 | height = image.size.height * (width / image.size.width) 55 | } else { 56 | height = view.frame.height 57 | width = image.size.width * (height / image.size.height) 58 | } 59 | 60 | preferredContentSize = CGSize(width: width, height: height) 61 | } 62 | } 63 | 64 | /// Displays the name of the image 65 | private class PhotoDetailViewController: UIViewController { 66 | private let imageName: String 67 | private let imageNameLabel = UILabel() 68 | 69 | init(imageName: String) { 70 | self.imageName = imageName 71 | super.init(nibName: nil, bundle: nil) 72 | } 73 | 74 | required init?(coder: NSCoder) { 75 | fatalError("init(coder:) has not been implemented") 76 | } 77 | 78 | override func viewDidLoad() { 79 | super.viewDidLoad() 80 | 81 | navigationItem.title = imageName.capitalized 82 | view.backgroundColor = .secondarySystemBackground 83 | 84 | imageNameLabel.font = UIFont.preferredFont(forTextStyle: .largeTitle) 85 | imageNameLabel.textColor = .label 86 | imageNameLabel.textAlignment = .center 87 | imageNameLabel.text = imageName.capitalized 88 | imageNameLabel.sizeToFit() 89 | view.addSubview(imageNameLabel) 90 | } 91 | 92 | override func viewDidLayoutSubviews() { 93 | super.viewDidLayoutSubviews() 94 | imageNameLabel.center = view.center 95 | } 96 | } 97 | 98 | /// A collection view cell that displays an image 99 | private class PhotoCell: UICollectionViewCell { 100 | private let imageView = UIImageView() 101 | 102 | override init(frame: CGRect) { 103 | super.init(frame: frame) 104 | 105 | imageView.clipsToBounds = true 106 | imageView.contentMode = .scaleAspectFill 107 | imageView.autoresizingMask = [.flexibleWidth, .flexibleHeight] 108 | imageView.frame = contentView.bounds 109 | contentView.addSubview(imageView) 110 | } 111 | 112 | required init?(coder: NSCoder) { 113 | fatalError("init(coder:) has not been implemented") 114 | } 115 | 116 | func display(imageNamed imageName: String) { 117 | imageView.image = UIImage(named: imageName) 118 | } 119 | } 120 | 121 | class VCPreviewCollectionViewController: UICollectionViewController, ContextMenuDemo { 122 | 123 | // MARK: ContextMenuDemo 124 | 125 | static var title: String { return "UIViewController (Collection View)" } 126 | 127 | // MARK: CollectionViewController 128 | 129 | private let identifier = "cell" 130 | 131 | init() { 132 | super.init(collectionViewLayout: Self.makeCollectionViewLayout()) 133 | } 134 | 135 | @available(*, unavailable) 136 | required init?(coder: NSCoder) { 137 | fatalError("init(coder:) has not been implemented") 138 | } 139 | 140 | override func viewDidLoad() { 141 | super.viewDidLoad() 142 | 143 | navigationItem.title = Self.title 144 | 145 | collectionView.register(PhotoCell.self, forCellWithReuseIdentifier: identifier) 146 | collectionView.backgroundColor = .systemBackground 147 | collectionView.dataSource = self 148 | collectionView.delegate = self 149 | } 150 | 151 | private static func makeCollectionViewLayout() -> UICollectionViewLayout { 152 | let itemSize = NSCollectionLayoutSize(widthDimension: .fractionalWidth(1.0 / 3), heightDimension: .fractionalHeight(1)) 153 | let item = NSCollectionLayoutItem(layoutSize: itemSize) 154 | 155 | let groupSize = NSCollectionLayoutSize(widthDimension: .fractionalWidth(1), heightDimension: .fractionalWidth(1.0 / 3)) 156 | let group = NSCollectionLayoutGroup.horizontal(layoutSize: groupSize, subitem: item, count: 3) 157 | group.interItemSpacing = .fixed(1) 158 | 159 | let section = NSCollectionLayoutSection(group: group) 160 | section.interGroupSpacing = 1 161 | 162 | return UICollectionViewCompositionalLayout(section: section) 163 | } 164 | 165 | // MARK: - UICollectionViewDelegate 166 | 167 | /* 168 | 169 | The `previewProvider` argument needs a function 170 | that returns a view controller. Here we configure a 171 | preview with the image at the items index. 172 | 173 | When creating our configuration, we'll specify an 174 | identifier so that we can tell which item is being 175 | previewed in `willPerformPreviewActionForMenuWith`. 176 | Then we can push a different detail view for that item. 177 | 178 | */ 179 | 180 | override func collectionView(_ collectionView: UICollectionView, contextMenuConfigurationForItemAt indexPath: IndexPath, point: CGPoint) -> UIContextMenuConfiguration? { 181 | 182 | // We have to create an NSString since the identifier must conform to NSCopying 183 | let identifier = NSString(string: Fixtures.images[indexPath.row]) 184 | 185 | // Create our configuration with an indentifier 186 | return UIContextMenuConfiguration(identifier: identifier, previewProvider: { 187 | return PhotoPreviewViewController(imageName: Fixtures.images[indexPath.row]) 188 | }, actionProvider: { suggestedActions in 189 | return self.makeDefaultDemoMenu() 190 | }) 191 | } 192 | 193 | override func collectionView(_ collectionView: UICollectionView, willPerformPreviewActionForMenuWith configuration: UIContextMenuConfiguration, animator: UIContextMenuInteractionCommitAnimating) { 194 | animator.addCompletion { 195 | 196 | // We should have our image name set as the identifier of the configuration 197 | if let identifier = configuration.identifier as? String { 198 | let viewController = PhotoDetailViewController(imageName: identifier) 199 | self.show(viewController, sender: self) 200 | } 201 | } 202 | } 203 | 204 | // MARK: - UICollectionViewDataSource 205 | 206 | override func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int { 207 | return Fixtures.images.count 208 | } 209 | 210 | override func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell { 211 | let cell = collectionView.dequeueReusableCell(withReuseIdentifier: identifier, for: indexPath) as! PhotoCell 212 | cell.display(imageNamed: Fixtures.images[indexPath.row]) 213 | return cell 214 | } 215 | } 216 | -------------------------------------------------------------------------------- /ContextMenu/Context Menu Demo/More Features/Custom Previews/VCPreviewSingleViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // VCPreviewSingleViewController.swift 3 | // ContextMenu 4 | // 5 | // Created by Kyle Bashour on 8/20/19. 6 | // Copyright © 2019 Kyle Bashour. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | /* 12 | 13 | This view controller displays a square that can open a menu, and uses a view controller for the menu preview. 14 | When the preview is tapped, it pushes that view controller. 15 | 16 | */ 17 | 18 | 19 | /// A view controller used for previewing and when an item is selected 20 | private class MountainsPreviewViewController: UIViewController { 21 | private let imageView = UIImageView() 22 | 23 | override func viewDidLoad() { 24 | super.viewDidLoad() 25 | 26 | navigationItem.title = "Mountains" 27 | let mountains = UIImage(named: "mountains")! 28 | 29 | imageView.image = mountains 30 | imageView.clipsToBounds = true 31 | imageView.contentMode = .scaleAspectFill 32 | imageView.translatesAutoresizingMaskIntoConstraints = false 33 | view.addSubview(imageView) 34 | 35 | NSLayoutConstraint.activate([ 36 | imageView.leftAnchor.constraint(equalTo: view.leftAnchor), 37 | imageView.rightAnchor.constraint(equalTo: view.rightAnchor), 38 | imageView.topAnchor.constraint(equalTo: view.topAnchor), 39 | imageView.bottomAnchor.constraint(equalTo: view.bottomAnchor), 40 | ]) 41 | 42 | // The preview will size to the preferredContentSize, which can be useful 43 | // for displaying a preview with the dimension of an image, for example. 44 | // Unlike peek and pop, it doesn't automatically scale down for you. 45 | 46 | let width = view.bounds.width 47 | let height = mountains.size.height * (width / mountains.size.width) 48 | preferredContentSize = CGSize(width: width, height: height) 49 | } 50 | } 51 | 52 | class VCPreviewSingleViewController: UIViewController, ContextMenuDemo { 53 | 54 | // MARK: ContextMenuDemo 55 | 56 | static var title: String { return "UIViewController (Single View)" } 57 | 58 | // MARK: CustomPreviewController 59 | 60 | private let photoView = UIImageView() 61 | 62 | override func viewDidLoad() { 63 | super.viewDidLoad() 64 | 65 | navigationItem.title = Self.title 66 | view.backgroundColor = .systemBackground 67 | 68 | photoView.image = UIImage(named: "mountains") 69 | photoView.contentMode = .scaleAspectFill 70 | photoView.clipsToBounds = true 71 | photoView.isUserInteractionEnabled = true 72 | photoView.frame.size = .init(width: 100, height: 100) 73 | view.addSubview(photoView) 74 | 75 | /* 76 | 77 | Here we create an interaction, give it a delegate, and 78 | add it to a view. This tells UIKit to call the delegate 79 | methods when the view is long-press or 3D touched, and 80 | display a menu if the delegate returns one. 81 | 82 | */ 83 | 84 | let interaction = UIContextMenuInteraction(delegate: self) 85 | photoView.addInteraction(interaction) 86 | } 87 | 88 | override func viewDidLayoutSubviews() { 89 | super.viewDidLayoutSubviews() 90 | photoView.center = view.center 91 | } 92 | } 93 | 94 | extension VCPreviewSingleViewController: UIContextMenuInteractionDelegate { 95 | 96 | /* 97 | 98 | The `previewProvider` argument needs a function 99 | that returns a view controller. You can do this with a 100 | closure, or pass in a method that creates the view controller 101 | (in this case, the preview view controller initializer). 102 | 103 | We can also implement `willPerformPreviewActionForMenuWith` 104 | to respond to the user tapping on the preview. 105 | 106 | */ 107 | 108 | func contextMenuInteraction(_ interaction: UIContextMenuInteraction, configurationForMenuAtLocation location: CGPoint) -> UIContextMenuConfiguration? { 109 | return UIContextMenuConfiguration(identifier: nil, previewProvider: MountainsPreviewViewController.init) { suggestedActions in 110 | return self.makeDefaultDemoMenu() 111 | } 112 | } 113 | 114 | func contextMenuInteraction(_ interaction: UIContextMenuInteraction, willPerformPreviewActionForMenuWith configuration: UIContextMenuConfiguration, animator: UIContextMenuInteractionCommitAnimating) { 115 | 116 | // If we used a view controller for our preview, we can pull it out of the animator and show it once the commit animation is complete. 117 | animator.addCompletion { 118 | if let viewController = animator.previewViewController { 119 | self.show(viewController, sender: self) 120 | } 121 | } 122 | } 123 | } 124 | -------------------------------------------------------------------------------- /ContextMenu/Context Menu Demo/More Features/Custom Previews/VCTargetedPreviewViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // CustomTargetedPreviewViewController.swift 3 | // ContextMenu 4 | // 5 | // Created by Kyle Bashour on 8/20/19. 6 | // Copyright © 2019 Kyle Bashour. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | /* 12 | 13 | This view controller displays a list of icons with their names, and has a custom preview with the icon and 14 | its name when the menu is opened. It animates the preview in from from the cell image to the center of the view, 15 | and animates back to the cell image when dismissing. 16 | 17 | */ 18 | 19 | /// This view controller previews an icon and its name 20 | private class PreviewViewViewController: UIViewController { 21 | private let imageView = UIImageView() 22 | private let label = UILabel() 23 | 24 | private lazy var stackView = UIStackView(arrangedSubviews: [imageView, label]) 25 | 26 | init(systemImageName: String) { 27 | super.init(nibName: nil, bundle: nil) 28 | 29 | view.backgroundColor = .secondarySystemBackground 30 | 31 | imageView.image = UIImage(systemName: systemImageName) 32 | imageView.tintColor = .systemBlue 33 | imageView.contentMode = .scaleAspectFit 34 | 35 | label.text = systemImageName 36 | label.textColor = .secondaryLabel 37 | 38 | stackView.spacing = 8 39 | stackView.axis = .vertical 40 | stackView.alignment = .center 41 | stackView.layoutMargins = .init(top: 8, left: 16, bottom: 8, right: 16) 42 | stackView.isLayoutMarginsRelativeArrangement = true 43 | stackView.translatesAutoresizingMaskIntoConstraints = false 44 | view.addSubview(stackView) 45 | 46 | NSLayoutConstraint.activate([ 47 | imageView.widthAnchor.constraint(equalToConstant: 80), 48 | imageView.heightAnchor.constraint(equalToConstant: 80), 49 | 50 | stackView.centerXAnchor.constraint(equalTo: view.centerXAnchor), 51 | stackView.centerYAnchor.constraint(equalTo: view.centerYAnchor), 52 | ]) 53 | 54 | preferredContentSize = stackView.systemLayoutSizeFitting(UIView.layoutFittingCompressedSize) 55 | } 56 | 57 | required init?(coder: NSCoder) { 58 | fatalError("init(coder:) has not been implemented") 59 | } 60 | } 61 | 62 | class VCTargetedPreviewViewController: UITableViewController, ContextMenuDemo { 63 | 64 | // MARK: ContextMenuDemo 65 | 66 | static var title: String { return "UITargetedPreview with Preview Provider" } 67 | 68 | // MARK: CustomPreviewTableViewController 69 | 70 | private let identifier = "identifier" 71 | 72 | override func viewDidLoad() { 73 | super.viewDidLoad() 74 | 75 | navigationItem.title = Self.title 76 | tableView.allowsSelection = false 77 | tableView.register(UITableViewCell.self, forCellReuseIdentifier: identifier) 78 | } 79 | 80 | private func makeTargetedPreview(for configuration: UIContextMenuConfiguration) -> UITargetedPreview? { 81 | 82 | // Ensure we can get the expected identifier 83 | guard let identifier = configuration.identifier as? String else { return nil } 84 | 85 | // Get the current index of the model 86 | guard let row = Fixtures.cloudSymbols.firstIndex(of: identifier) else { return nil } 87 | 88 | // Get the image view in order to create a transform from its frame for our animation 89 | guard let cellImageView = tableView.cellForRow(at: .init(row: row, section: 0))?.imageView else { return nil } 90 | 91 | // Create a custom shape for our highlight/dismissal preview 92 | let visiblePath = UIBezierPath(roundedRect: cellImageView.bounds, cornerRadius: 3) 93 | 94 | // Configure our parameters 95 | let parameters = UIPreviewParameters() 96 | parameters.visiblePath = visiblePath 97 | 98 | // Return the custom targeted preview 99 | return UITargetedPreview(view: cellImageView, parameters: parameters) 100 | } 101 | 102 | // MARK: - UITableViewDataSource 103 | 104 | override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { 105 | return Fixtures.cloudSymbols.count 106 | } 107 | 108 | override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { 109 | let cell = tableView.dequeueReusableCell(withIdentifier: identifier, for: indexPath) 110 | cell.textLabel?.text = Fixtures.cloudSymbols[indexPath.row] 111 | cell.imageView?.image = UIImage(systemName: Fixtures.cloudSymbols[indexPath.row]) 112 | cell.imageView?.backgroundColor = .systemBackground 113 | cell.accessoryType = .disclosureIndicator 114 | return cell 115 | } 116 | 117 | // MARK: - UITableViewDelegate 118 | 119 | /* 120 | 121 | In this example, we'll create a targeted preview 122 | with the cells image view. This tells the system 123 | to animate to and from the image view instead of 124 | the cell itself. 125 | 126 | */ 127 | 128 | override func tableView(_ tableView: UITableView, contextMenuConfigurationForRowAt indexPath: IndexPath, point: CGPoint) -> UIContextMenuConfiguration? { 129 | 130 | // We have to create an NSString since the identifier must conform to NSCopying 131 | let symbolName = Fixtures.cloudSymbols[indexPath.row] 132 | let identifier = NSString(string: symbolName) 133 | 134 | // Create our configuration with an indentifier 135 | return UIContextMenuConfiguration(identifier: identifier, previewProvider: { 136 | return PreviewViewViewController(systemImageName: symbolName) 137 | }, actionProvider: { suggestedActions in 138 | return self.makeDefaultDemoMenu() 139 | }) 140 | } 141 | 142 | override func tableView(_ tableView: UITableView, previewForHighlightingContextMenuWithConfiguration configuration: UIContextMenuConfiguration) -> UITargetedPreview? { 143 | return self.makeTargetedPreview(for: configuration) 144 | } 145 | 146 | override func tableView(_ tableView: UITableView, previewForDismissingContextMenuWithConfiguration configuration: UIContextMenuConfiguration) -> UITargetedPreview? { 147 | return self.makeTargetedPreview(for: configuration) 148 | } 149 | 150 | override func tableView(_ tableView: UITableView, willPerformPreviewActionForMenuWith configuration: UIContextMenuConfiguration, animator: UIContextMenuInteractionCommitAnimating) { 151 | 152 | // If we used a view controller for our preview, we can pull it out of the animator and show it once the commit animation is complete. 153 | animator.addCompletion { 154 | if let viewController = animator.previewViewController { 155 | self.show(viewController, sender: self) 156 | } 157 | } 158 | } 159 | } 160 | -------------------------------------------------------------------------------- /ContextMenu/Context Menu Demo/More Features/Submenus/InlineSubmenuViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // InlineSubmenuViewController.swift 3 | // ContextMenu 4 | // 5 | // Created by Kyle Bashour on 8/20/19. 6 | // Copyright © 2019 Kyle Bashour. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | /* 12 | 13 | This view controller displays a square that can open a menu, and the menu has a submenu shown inline with a separator. 14 | "Delete" is itself a submenu, which opens a confirmation menu when tapped. 15 | 16 | --------------------- 17 | | Share | 18 | --------------------- 19 | --------------------- 20 | | Rename | 21 | --------------------- 22 | | Delete | 23 | --------------------- 24 | 25 | User taps delete, and the menu transforms: 26 | 27 | --------------------- 28 | | Cancel | 29 | --------------------- 30 | | Delete | 31 | --------------------- 32 | 33 | */ 34 | 35 | class InlineSubmenuViewController: UIViewController, ContextMenuDemo { 36 | 37 | // MARK: ContextMenuDemo 38 | 39 | static var title: String { return "Inline Submenu (Separators)" } 40 | 41 | // MARK: InlineSubmenuViewController 42 | 43 | private let menuView = UIView() 44 | 45 | override func viewDidLoad() { 46 | super.viewDidLoad() 47 | 48 | navigationItem.title = Self.title 49 | view.backgroundColor = .systemBackground 50 | 51 | menuView.backgroundColor = .systemBlue 52 | menuView.frame.size = .init(width: 100, height: 100) 53 | view.addSubview(menuView) 54 | 55 | let interaction = UIContextMenuInteraction(delegate: self) 56 | menuView.addInteraction(interaction) 57 | } 58 | 59 | override func viewDidLayoutSubviews() { 60 | super.viewDidLayoutSubviews() 61 | menuView.center = view.center 62 | } 63 | } 64 | 65 | extension InlineSubmenuViewController: UIContextMenuInteractionDelegate { 66 | 67 | /* 68 | 69 | When we create our menu, we'll use the exact same items 70 | as the basic menu, but group "rename" and "delete" into 71 | a submenu titled "Edit..." 72 | 73 | We'll also specify the `displayInline` option to show it at 74 | the top level with a separator. 75 | 76 | */ 77 | 78 | func contextMenuInteraction(_ interaction: UIContextMenuInteraction, configurationForMenuAtLocation location: CGPoint) -> UIContextMenuConfiguration? { 79 | return UIContextMenuConfiguration(identifier: nil, previewProvider: nil) { suggestedActions in 80 | 81 | let share = UIAction(title: "Share", image: UIImage(systemName: "square.and.arrow.up")) { action in } 82 | let rename = UIAction(title: "Rename", image: UIImage(systemName: "square.and.pencil")) { action in } 83 | 84 | let deleteCancel = UIAction(title: "Cancel", image: UIImage(systemName: "xmark")) { action in } 85 | let deleteConfirmation = UIAction(title: "Delete", image: UIImage(systemName: "checkmark"), attributes: .destructive) { action in } 86 | 87 | // The delete sub-menu is created like the top-level menu, but we also specify an image and options 88 | let delete = UIMenu(title: "Delete", image: UIImage(systemName: "trash"), options: .destructive, children: [deleteCancel, deleteConfirmation]) 89 | 90 | // The edit sub-menu is created like the top-level menu, but we also specify it should be inline... 91 | let edit = UIMenu(title: "Edit...", options: .displayInline, children: [rename, delete]) 92 | 93 | // ...then we add edit as a child of the main menu. 94 | return UIMenu(title: "", children: [share, edit]) 95 | } 96 | } 97 | } 98 | -------------------------------------------------------------------------------- /ContextMenu/Context Menu Demo/More Features/Submenus/SubmenuViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // SubmenuViewController.swift 3 | // ContextMenu 4 | // 5 | // Created by Kyle Bashour on 8/20/19. 6 | // Copyright © 2019 Kyle Bashour. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | /* 12 | 13 | This view controller displays a square that can open a menu, and the menu has an "Edit" submenu. When "Edit" is tapped, 14 | the submenu is opened and displays rename/delete options. "Delete" is itself a submenu, allowing the user to confirm 15 | (always a good idea for destructive actions). 16 | 17 | --------------------- 18 | | Share | 19 | --------------------- 20 | | Edit... | 21 | --------------------- 22 | 23 | User taps edit, and the menu transforms: 24 | 25 | --------------------- 26 | | Rename | 27 | --------------------- 28 | | Delete | 29 | --------------------- 30 | 31 | User taps delete, and the menu transforms again: 32 | 33 | --------------------- 34 | | Cancel | 35 | --------------------- 36 | | Delete | 37 | --------------------- 38 | 39 | */ 40 | 41 | class SubmenuViewController: UIViewController, ContextMenuDemo { 42 | 43 | // MARK: ContextMenuDemo 44 | 45 | static var title: String { return "Submenu" } 46 | 47 | // MARK: SubmenuViewController 48 | 49 | private let menuView = UIView() 50 | 51 | override func viewDidLoad() { 52 | super.viewDidLoad() 53 | 54 | navigationItem.title = Self.title 55 | view.backgroundColor = .systemBackground 56 | 57 | menuView.backgroundColor = .systemBlue 58 | menuView.frame.size = .init(width: 100, height: 100) 59 | view.addSubview(menuView) 60 | 61 | let interaction = UIContextMenuInteraction(delegate: self) 62 | menuView.addInteraction(interaction) 63 | } 64 | 65 | override func viewDidLayoutSubviews() { 66 | super.viewDidLayoutSubviews() 67 | menuView.center = view.center 68 | } 69 | } 70 | 71 | extension SubmenuViewController: UIContextMenuInteractionDelegate { 72 | 73 | /* 74 | 75 | When we create our menu, we'll use the exact same items 76 | as the basic menu, but group "rename" and "delete" into 77 | a submenu titled "Edit..." 78 | 79 | */ 80 | 81 | func contextMenuInteraction(_ interaction: UIContextMenuInteraction, configurationForMenuAtLocation location: CGPoint) -> UIContextMenuConfiguration? { 82 | return UIContextMenuConfiguration(identifier: nil, previewProvider: nil) { suggestedActions in 83 | 84 | let share = UIAction(title: "Share", image: UIImage(systemName: "square.and.arrow.up")) { action in } 85 | let rename = UIAction(title: "Rename", image: UIImage(systemName: "square.and.pencil")) { action in } 86 | 87 | let deleteCancel = UIAction(title: "Cancel", image: UIImage(systemName: "xmark")) { action in } 88 | let deleteConfirmation = UIAction(title: "Delete", image: UIImage(systemName: "checkmark"), attributes: .destructive) { action in } 89 | 90 | // The delete sub-menu is created like the top-level menu, but we also specify an image and options 91 | let delete = UIMenu(title: "Delete", image: UIImage(systemName: "trash"), options: .destructive, children: [deleteCancel, deleteConfirmation]) 92 | 93 | // The edit menu adds delete as a child, just like an action... 94 | let edit = UIMenu(title: "Edit...", children: [rename, delete]) 95 | 96 | // ...then we add edit as a child of the main menu. 97 | return UIMenu(title: "", children: [share, edit]) 98 | } 99 | } 100 | } 101 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # iOS 13 Context Menu Demo 2 | 3 | Demo app for iOS context menus, including menu configuration and advanced preview options. Check out the blog post: [https://kylebashour.com/posts/context-menu-guide](https://kylebashour.com/posts/context-menu-guide). 4 | 5 | | Collection Views | Submenus | View Controller Previews | Table Views | Targeted Previews | 6 | |-|-|-|-|-| 7 | | ![](images/collection.png) | ![](images/nesting.png) | ![](images/photo.png) | ![](images/targeted-1.png) | ![](images/targeted-2.png) | 8 | -------------------------------------------------------------------------------- /images/collection.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kylebshr/context-menus/88844a321c8a90e4882856cdec286b626ef10efc/images/collection.png -------------------------------------------------------------------------------- /images/nesting.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kylebshr/context-menus/88844a321c8a90e4882856cdec286b626ef10efc/images/nesting.png -------------------------------------------------------------------------------- /images/photo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kylebshr/context-menus/88844a321c8a90e4882856cdec286b626ef10efc/images/photo.png -------------------------------------------------------------------------------- /images/targeted-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kylebshr/context-menus/88844a321c8a90e4882856cdec286b626ef10efc/images/targeted-1.png -------------------------------------------------------------------------------- /images/targeted-2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kylebshr/context-menus/88844a321c8a90e4882856cdec286b626ef10efc/images/targeted-2.png --------------------------------------------------------------------------------