├── .gitignore ├── AutoPopupMenuControllerDemo ├── AutoPopupMenuControllerDemo.xcodeproj │ ├── project.pbxproj │ └── project.xcworkspace │ │ └── contents.xcworkspacedata └── AutoPopupMenuControllerDemo │ ├── AppDelegate.swift │ ├── Assets.xcassets │ ├── AppIcon.appiconset │ │ └── Contents.json │ ├── ColorImage.imageset │ │ ├── ColorImage.pdf │ │ └── Contents.json │ ├── Contents.json │ └── Image.imageset │ │ ├── Contents.json │ │ └── yy.pdf │ ├── Base.lproj │ ├── LaunchScreen.storyboard │ └── Main.storyboard │ ├── Info.plist │ └── ViewController.swift ├── Demo-ObjC ├── Demo-ObjC.xcodeproj │ ├── project.pbxproj │ └── project.xcworkspace │ │ └── contents.xcworkspacedata └── Demo-ObjC │ ├── AppDelegate.h │ ├── AppDelegate.m │ ├── Base.lproj │ └── Main.storyboard │ ├── Info.plist │ ├── ViewController.h │ ├── ViewController.m │ └── main.m ├── Demo-SPM ├── Demo-SPM.xcodeproj │ ├── project.pbxproj │ └── project.xcworkspace │ │ └── contents.xcworkspacedata └── Demo-SPM │ └── Info.plist ├── Demo ├── Demo.xcodeproj │ ├── project.pbxproj │ └── project.xcworkspace │ │ └── contents.xcworkspacedata └── Demo │ ├── AppDelegate.swift │ ├── Assets.xcassets │ ├── ColorImage.imageset │ │ ├── ColorImage.pdf │ │ └── Contents.json │ ├── Contents.json │ └── Image.imageset │ │ ├── Contents.json │ │ └── yy.pdf │ ├── Base.lproj │ ├── LaunchScreen.storyboard │ └── Main.storyboard │ ├── Info.plist │ └── ViewController.swift ├── LICENSE ├── MenuItemKit.podspec ├── MenuItemKit.xcodeproj ├── project.pbxproj ├── project.xcworkspace │ └── contents.xcworkspacedata └── xcshareddata │ └── xcschemes │ └── MenuItemKit.xcscheme ├── MenuItemKit ├── Info.plist ├── MenuItemKit.h ├── ObjCSwizzlings │ ├── Swizzlings.m │ └── include │ │ └── Headers.h └── Swift │ ├── Internals.swift │ ├── Swizzlings.swift │ ├── UIMenuController.swift │ └── UIMenuItem.swift ├── Package.swift ├── README.md └── Screenshot.png /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | .swiftpm 3 | 4 | # Xcode 5 | # 6 | # gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore 7 | 8 | ## Build generated 9 | build/ 10 | DerivedData/ 11 | 12 | ## Various settings 13 | *.pbxuser 14 | !default.pbxuser 15 | *.mode1v3 16 | !default.mode1v3 17 | *.mode2v3 18 | !default.mode2v3 19 | *.perspectivev3 20 | !default.perspectivev3 21 | xcuserdata/ 22 | xcshareddata/ 23 | 24 | ## Other 25 | *.moved-aside 26 | *.xcuserstate 27 | 28 | ## Obj-C/Swift specific 29 | *.hmap 30 | *.ipa 31 | *.dSYM.zip 32 | *.dSYM 33 | 34 | ## Playgrounds 35 | timeline.xctimeline 36 | playground.xcworkspace 37 | 38 | # Swift Package Manager 39 | # 40 | # Add this line if you want to avoid checking in source code from Swift Package Manager dependencies. 41 | # Packages/ 42 | .build/ 43 | 44 | # CocoaPods 45 | # 46 | # We recommend against adding the Pods directory to your .gitignore. However 47 | # you should judge for yourself, the pros and cons are mentioned at: 48 | # https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control 49 | # 50 | # Pods/ 51 | 52 | # Carthage 53 | # 54 | # Add this line if you want to avoid checking in source code from Carthage dependencies. 55 | Carthage/Checkouts 56 | 57 | Carthage/Build 58 | -------------------------------------------------------------------------------- /AutoPopupMenuControllerDemo/AutoPopupMenuControllerDemo.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 48; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | E053D58720430A5F001D01B5 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = E053D58620430A5F001D01B5 /* AppDelegate.swift */; }; 11 | E053D58920430A5F001D01B5 /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = E053D58820430A5F001D01B5 /* ViewController.swift */; }; 12 | E053D58C20430A5F001D01B5 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = E053D58A20430A5F001D01B5 /* Main.storyboard */; }; 13 | E053D58E20430A5F001D01B5 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = E053D58D20430A5F001D01B5 /* Assets.xcassets */; }; 14 | E053D59120430A5F001D01B5 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = E053D58F20430A5F001D01B5 /* LaunchScreen.storyboard */; }; 15 | E053D5A220430B5E001D01B5 /* MenuItemKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = E053D59E20430B4E001D01B5 /* MenuItemKit.framework */; }; 16 | /* End PBXBuildFile section */ 17 | 18 | /* Begin PBXContainerItemProxy section */ 19 | E053D59D20430B4E001D01B5 /* PBXContainerItemProxy */ = { 20 | isa = PBXContainerItemProxy; 21 | containerPortal = E053D59820430B4D001D01B5 /* MenuItemKit.xcodeproj */; 22 | proxyType = 2; 23 | remoteGlobalIDString = E0EFAE4A1C49F99300334D78; 24 | remoteInfo = MenuItemKit; 25 | }; 26 | E053D59F20430B4E001D01B5 /* PBXContainerItemProxy */ = { 27 | isa = PBXContainerItemProxy; 28 | containerPortal = E053D59820430B4D001D01B5 /* MenuItemKit.xcodeproj */; 29 | proxyType = 2; 30 | remoteGlobalIDString = E0EFAE541C49F99400334D78; 31 | remoteInfo = MenuItemKitTests; 32 | }; 33 | /* End PBXContainerItemProxy section */ 34 | 35 | /* Begin PBXFileReference section */ 36 | E053D58320430A5F001D01B5 /* AutoPopupMenuControllerDemo.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = AutoPopupMenuControllerDemo.app; sourceTree = BUILT_PRODUCTS_DIR; }; 37 | E053D58620430A5F001D01B5 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 38 | E053D58820430A5F001D01B5 /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = ""; }; 39 | E053D58B20430A5F001D01B5 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 40 | E053D58D20430A5F001D01B5 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 41 | E053D59020430A5F001D01B5 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 42 | E053D59220430A5F001D01B5 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 43 | E053D59820430B4D001D01B5 /* MenuItemKit.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = MenuItemKit.xcodeproj; path = ../MenuItemKit.xcodeproj; sourceTree = ""; }; 44 | /* End PBXFileReference section */ 45 | 46 | /* Begin PBXFrameworksBuildPhase section */ 47 | E053D58020430A5F001D01B5 /* Frameworks */ = { 48 | isa = PBXFrameworksBuildPhase; 49 | buildActionMask = 2147483647; 50 | files = ( 51 | E053D5A220430B5E001D01B5 /* MenuItemKit.framework in Frameworks */, 52 | ); 53 | runOnlyForDeploymentPostprocessing = 0; 54 | }; 55 | /* End PBXFrameworksBuildPhase section */ 56 | 57 | /* Begin PBXGroup section */ 58 | E053D57A20430A5F001D01B5 = { 59 | isa = PBXGroup; 60 | children = ( 61 | E053D59820430B4D001D01B5 /* MenuItemKit.xcodeproj */, 62 | E053D58520430A5F001D01B5 /* AutoPopupMenuControllerDemo */, 63 | E053D58420430A5F001D01B5 /* Products */, 64 | E053D5A120430B5E001D01B5 /* Frameworks */, 65 | ); 66 | sourceTree = ""; 67 | }; 68 | E053D58420430A5F001D01B5 /* Products */ = { 69 | isa = PBXGroup; 70 | children = ( 71 | E053D58320430A5F001D01B5 /* AutoPopupMenuControllerDemo.app */, 72 | ); 73 | name = Products; 74 | sourceTree = ""; 75 | }; 76 | E053D58520430A5F001D01B5 /* AutoPopupMenuControllerDemo */ = { 77 | isa = PBXGroup; 78 | children = ( 79 | E053D58620430A5F001D01B5 /* AppDelegate.swift */, 80 | E053D58820430A5F001D01B5 /* ViewController.swift */, 81 | E053D58A20430A5F001D01B5 /* Main.storyboard */, 82 | E053D58D20430A5F001D01B5 /* Assets.xcassets */, 83 | E053D58F20430A5F001D01B5 /* LaunchScreen.storyboard */, 84 | E053D59220430A5F001D01B5 /* Info.plist */, 85 | ); 86 | path = AutoPopupMenuControllerDemo; 87 | sourceTree = ""; 88 | }; 89 | E053D59920430B4D001D01B5 /* Products */ = { 90 | isa = PBXGroup; 91 | children = ( 92 | E053D59E20430B4E001D01B5 /* MenuItemKit.framework */, 93 | E053D5A020430B4E001D01B5 /* MenuItemKitTests.xctest */, 94 | ); 95 | name = Products; 96 | sourceTree = ""; 97 | }; 98 | E053D5A120430B5E001D01B5 /* Frameworks */ = { 99 | isa = PBXGroup; 100 | children = ( 101 | ); 102 | name = Frameworks; 103 | sourceTree = ""; 104 | }; 105 | /* End PBXGroup section */ 106 | 107 | /* Begin PBXNativeTarget section */ 108 | E053D58220430A5F001D01B5 /* AutoPopupMenuControllerDemo */ = { 109 | isa = PBXNativeTarget; 110 | buildConfigurationList = E053D59520430A5F001D01B5 /* Build configuration list for PBXNativeTarget "AutoPopupMenuControllerDemo" */; 111 | buildPhases = ( 112 | E053D57F20430A5F001D01B5 /* Sources */, 113 | E053D58020430A5F001D01B5 /* Frameworks */, 114 | E053D58120430A5F001D01B5 /* Resources */, 115 | ); 116 | buildRules = ( 117 | ); 118 | dependencies = ( 119 | ); 120 | name = AutoPopupMenuControllerDemo; 121 | productName = AutoPopupMenuControllerDemo; 122 | productReference = E053D58320430A5F001D01B5 /* AutoPopupMenuControllerDemo.app */; 123 | productType = "com.apple.product-type.application"; 124 | }; 125 | /* End PBXNativeTarget section */ 126 | 127 | /* Begin PBXProject section */ 128 | E053D57B20430A5F001D01B5 /* Project object */ = { 129 | isa = PBXProject; 130 | attributes = { 131 | LastSwiftUpdateCheck = 0920; 132 | LastUpgradeCheck = 0930; 133 | ORGANIZATIONNAME = "Neo Xian-an CHEN"; 134 | TargetAttributes = { 135 | E053D58220430A5F001D01B5 = { 136 | CreatedOnToolsVersion = 9.2; 137 | ProvisioningStyle = Automatic; 138 | }; 139 | }; 140 | }; 141 | buildConfigurationList = E053D57E20430A5F001D01B5 /* Build configuration list for PBXProject "AutoPopupMenuControllerDemo" */; 142 | compatibilityVersion = "Xcode 8.0"; 143 | developmentRegion = en; 144 | hasScannedForEncodings = 0; 145 | knownRegions = ( 146 | en, 147 | Base, 148 | ); 149 | mainGroup = E053D57A20430A5F001D01B5; 150 | productRefGroup = E053D58420430A5F001D01B5 /* Products */; 151 | projectDirPath = ""; 152 | projectReferences = ( 153 | { 154 | ProductGroup = E053D59920430B4D001D01B5 /* Products */; 155 | ProjectRef = E053D59820430B4D001D01B5 /* MenuItemKit.xcodeproj */; 156 | }, 157 | ); 158 | projectRoot = ""; 159 | targets = ( 160 | E053D58220430A5F001D01B5 /* AutoPopupMenuControllerDemo */, 161 | ); 162 | }; 163 | /* End PBXProject section */ 164 | 165 | /* Begin PBXReferenceProxy section */ 166 | E053D59E20430B4E001D01B5 /* MenuItemKit.framework */ = { 167 | isa = PBXReferenceProxy; 168 | fileType = wrapper.framework; 169 | path = MenuItemKit.framework; 170 | remoteRef = E053D59D20430B4E001D01B5 /* PBXContainerItemProxy */; 171 | sourceTree = BUILT_PRODUCTS_DIR; 172 | }; 173 | E053D5A020430B4E001D01B5 /* MenuItemKitTests.xctest */ = { 174 | isa = PBXReferenceProxy; 175 | fileType = wrapper.cfbundle; 176 | path = MenuItemKitTests.xctest; 177 | remoteRef = E053D59F20430B4E001D01B5 /* PBXContainerItemProxy */; 178 | sourceTree = BUILT_PRODUCTS_DIR; 179 | }; 180 | /* End PBXReferenceProxy section */ 181 | 182 | /* Begin PBXResourcesBuildPhase section */ 183 | E053D58120430A5F001D01B5 /* Resources */ = { 184 | isa = PBXResourcesBuildPhase; 185 | buildActionMask = 2147483647; 186 | files = ( 187 | E053D59120430A5F001D01B5 /* LaunchScreen.storyboard in Resources */, 188 | E053D58E20430A5F001D01B5 /* Assets.xcassets in Resources */, 189 | E053D58C20430A5F001D01B5 /* Main.storyboard in Resources */, 190 | ); 191 | runOnlyForDeploymentPostprocessing = 0; 192 | }; 193 | /* End PBXResourcesBuildPhase section */ 194 | 195 | /* Begin PBXSourcesBuildPhase section */ 196 | E053D57F20430A5F001D01B5 /* Sources */ = { 197 | isa = PBXSourcesBuildPhase; 198 | buildActionMask = 2147483647; 199 | files = ( 200 | E053D58920430A5F001D01B5 /* ViewController.swift in Sources */, 201 | E053D58720430A5F001D01B5 /* AppDelegate.swift in Sources */, 202 | ); 203 | runOnlyForDeploymentPostprocessing = 0; 204 | }; 205 | /* End PBXSourcesBuildPhase section */ 206 | 207 | /* Begin PBXVariantGroup section */ 208 | E053D58A20430A5F001D01B5 /* Main.storyboard */ = { 209 | isa = PBXVariantGroup; 210 | children = ( 211 | E053D58B20430A5F001D01B5 /* Base */, 212 | ); 213 | name = Main.storyboard; 214 | sourceTree = ""; 215 | }; 216 | E053D58F20430A5F001D01B5 /* LaunchScreen.storyboard */ = { 217 | isa = PBXVariantGroup; 218 | children = ( 219 | E053D59020430A5F001D01B5 /* Base */, 220 | ); 221 | name = LaunchScreen.storyboard; 222 | sourceTree = ""; 223 | }; 224 | /* End PBXVariantGroup section */ 225 | 226 | /* Begin XCBuildConfiguration section */ 227 | E053D59320430A5F001D01B5 /* Debug */ = { 228 | isa = XCBuildConfiguration; 229 | buildSettings = { 230 | ALWAYS_SEARCH_USER_PATHS = NO; 231 | CLANG_ANALYZER_NONNULL = YES; 232 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 233 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; 234 | CLANG_CXX_LIBRARY = "libc++"; 235 | CLANG_ENABLE_MODULES = YES; 236 | CLANG_ENABLE_OBJC_ARC = YES; 237 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 238 | CLANG_WARN_BOOL_CONVERSION = YES; 239 | CLANG_WARN_COMMA = YES; 240 | CLANG_WARN_CONSTANT_CONVERSION = YES; 241 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 242 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 243 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 244 | CLANG_WARN_EMPTY_BODY = YES; 245 | CLANG_WARN_ENUM_CONVERSION = YES; 246 | CLANG_WARN_INFINITE_RECURSION = YES; 247 | CLANG_WARN_INT_CONVERSION = YES; 248 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 249 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 250 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 251 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 252 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 253 | CLANG_WARN_STRICT_PROTOTYPES = YES; 254 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 255 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; 256 | CLANG_WARN_UNREACHABLE_CODE = YES; 257 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 258 | CODE_SIGN_IDENTITY = "iPhone Developer"; 259 | COPY_PHASE_STRIP = NO; 260 | DEBUG_INFORMATION_FORMAT = dwarf; 261 | ENABLE_STRICT_OBJC_MSGSEND = YES; 262 | ENABLE_TESTABILITY = YES; 263 | GCC_C_LANGUAGE_STANDARD = gnu11; 264 | GCC_DYNAMIC_NO_PIC = NO; 265 | GCC_NO_COMMON_BLOCKS = YES; 266 | GCC_OPTIMIZATION_LEVEL = 0; 267 | GCC_PREPROCESSOR_DEFINITIONS = ( 268 | "DEBUG=1", 269 | "$(inherited)", 270 | ); 271 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 272 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 273 | GCC_WARN_UNDECLARED_SELECTOR = YES; 274 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 275 | GCC_WARN_UNUSED_FUNCTION = YES; 276 | GCC_WARN_UNUSED_VARIABLE = YES; 277 | IPHONEOS_DEPLOYMENT_TARGET = 11.2; 278 | MTL_ENABLE_DEBUG_INFO = YES; 279 | ONLY_ACTIVE_ARCH = YES; 280 | SDKROOT = iphoneos; 281 | SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; 282 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 283 | }; 284 | name = Debug; 285 | }; 286 | E053D59420430A5F001D01B5 /* Release */ = { 287 | isa = XCBuildConfiguration; 288 | buildSettings = { 289 | ALWAYS_SEARCH_USER_PATHS = NO; 290 | CLANG_ANALYZER_NONNULL = YES; 291 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 292 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; 293 | CLANG_CXX_LIBRARY = "libc++"; 294 | CLANG_ENABLE_MODULES = YES; 295 | CLANG_ENABLE_OBJC_ARC = YES; 296 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 297 | CLANG_WARN_BOOL_CONVERSION = YES; 298 | CLANG_WARN_COMMA = YES; 299 | CLANG_WARN_CONSTANT_CONVERSION = YES; 300 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 301 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 302 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 303 | CLANG_WARN_EMPTY_BODY = YES; 304 | CLANG_WARN_ENUM_CONVERSION = YES; 305 | CLANG_WARN_INFINITE_RECURSION = YES; 306 | CLANG_WARN_INT_CONVERSION = YES; 307 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 308 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 309 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 310 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 311 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 312 | CLANG_WARN_STRICT_PROTOTYPES = YES; 313 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 314 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; 315 | CLANG_WARN_UNREACHABLE_CODE = YES; 316 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 317 | CODE_SIGN_IDENTITY = "iPhone Developer"; 318 | COPY_PHASE_STRIP = NO; 319 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 320 | ENABLE_NS_ASSERTIONS = NO; 321 | ENABLE_STRICT_OBJC_MSGSEND = YES; 322 | GCC_C_LANGUAGE_STANDARD = gnu11; 323 | GCC_NO_COMMON_BLOCKS = YES; 324 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 325 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 326 | GCC_WARN_UNDECLARED_SELECTOR = YES; 327 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 328 | GCC_WARN_UNUSED_FUNCTION = YES; 329 | GCC_WARN_UNUSED_VARIABLE = YES; 330 | IPHONEOS_DEPLOYMENT_TARGET = 11.2; 331 | MTL_ENABLE_DEBUG_INFO = NO; 332 | SDKROOT = iphoneos; 333 | SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; 334 | VALIDATE_PRODUCT = YES; 335 | }; 336 | name = Release; 337 | }; 338 | E053D59620430A5F001D01B5 /* Debug */ = { 339 | isa = XCBuildConfiguration; 340 | buildSettings = { 341 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 342 | CODE_SIGN_STYLE = Automatic; 343 | INFOPLIST_FILE = AutoPopupMenuControllerDemo/Info.plist; 344 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 345 | PRODUCT_BUNDLE_IDENTIFIER = lazyapps.AutoPopupMenuControllerDemo; 346 | PRODUCT_NAME = "$(TARGET_NAME)"; 347 | SWIFT_VERSION = 5.0; 348 | TARGETED_DEVICE_FAMILY = "1,2"; 349 | }; 350 | name = Debug; 351 | }; 352 | E053D59720430A5F001D01B5 /* Release */ = { 353 | isa = XCBuildConfiguration; 354 | buildSettings = { 355 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 356 | CODE_SIGN_STYLE = Automatic; 357 | INFOPLIST_FILE = AutoPopupMenuControllerDemo/Info.plist; 358 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 359 | PRODUCT_BUNDLE_IDENTIFIER = lazyapps.AutoPopupMenuControllerDemo; 360 | PRODUCT_NAME = "$(TARGET_NAME)"; 361 | SWIFT_VERSION = 5.0; 362 | TARGETED_DEVICE_FAMILY = "1,2"; 363 | }; 364 | name = Release; 365 | }; 366 | /* End XCBuildConfiguration section */ 367 | 368 | /* Begin XCConfigurationList section */ 369 | E053D57E20430A5F001D01B5 /* Build configuration list for PBXProject "AutoPopupMenuControllerDemo" */ = { 370 | isa = XCConfigurationList; 371 | buildConfigurations = ( 372 | E053D59320430A5F001D01B5 /* Debug */, 373 | E053D59420430A5F001D01B5 /* Release */, 374 | ); 375 | defaultConfigurationIsVisible = 0; 376 | defaultConfigurationName = Release; 377 | }; 378 | E053D59520430A5F001D01B5 /* Build configuration list for PBXNativeTarget "AutoPopupMenuControllerDemo" */ = { 379 | isa = XCConfigurationList; 380 | buildConfigurations = ( 381 | E053D59620430A5F001D01B5 /* Debug */, 382 | E053D59720430A5F001D01B5 /* Release */, 383 | ); 384 | defaultConfigurationIsVisible = 0; 385 | defaultConfigurationName = Release; 386 | }; 387 | /* End XCConfigurationList section */ 388 | }; 389 | rootObject = E053D57B20430A5F001D01B5 /* Project object */; 390 | } 391 | -------------------------------------------------------------------------------- /AutoPopupMenuControllerDemo/AutoPopupMenuControllerDemo.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /AutoPopupMenuControllerDemo/AutoPopupMenuControllerDemo/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.swift 3 | // AutoPopupMenuControllerDemo 4 | // 5 | // Created by CHEN Xian-an on 25/02/2018. 6 | // Copyright © 2018 Neo Xian-an CHEN. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | @UIApplicationMain 12 | class AppDelegate: UIResponder, UIApplicationDelegate { 13 | var window: UIWindow? 14 | 15 | func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { 16 | // Override point for customization after application launch. 17 | return true 18 | } 19 | 20 | func applicationWillResignActive(_ application: UIApplication) { 21 | // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. 22 | // Use this method to pause ongoing tasks, disable timers, and invalidate graphics rendering callbacks. Games should use this method to pause the game. 23 | } 24 | 25 | func applicationDidEnterBackground(_ application: UIApplication) { 26 | // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. 27 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 28 | } 29 | 30 | func applicationWillEnterForeground(_ application: UIApplication) { 31 | // Called as part of the transition from the background to the active state; here you can undo many of the changes made on entering the background. 32 | } 33 | 34 | func applicationDidBecomeActive(_ application: UIApplication) { 35 | // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. 36 | } 37 | 38 | func applicationWillTerminate(_ application: UIApplication) { 39 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /AutoPopupMenuControllerDemo/AutoPopupMenuControllerDemo/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 | } -------------------------------------------------------------------------------- /AutoPopupMenuControllerDemo/AutoPopupMenuControllerDemo/Assets.xcassets/ColorImage.imageset/ColorImage.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cxa/MenuItemKit/365321523300be357dd0665cfe048c4074203355/AutoPopupMenuControllerDemo/AutoPopupMenuControllerDemo/Assets.xcassets/ColorImage.imageset/ColorImage.pdf -------------------------------------------------------------------------------- /AutoPopupMenuControllerDemo/AutoPopupMenuControllerDemo/Assets.xcassets/ColorImage.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "ColorImage.pdf" 6 | } 7 | ], 8 | "info" : { 9 | "version" : 1, 10 | "author" : "xcode" 11 | } 12 | } -------------------------------------------------------------------------------- /AutoPopupMenuControllerDemo/AutoPopupMenuControllerDemo/Assets.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "version" : 1, 4 | "author" : "xcode" 5 | } 6 | } -------------------------------------------------------------------------------- /AutoPopupMenuControllerDemo/AutoPopupMenuControllerDemo/Assets.xcassets/Image.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "yy.pdf" 6 | } 7 | ], 8 | "info" : { 9 | "version" : 1, 10 | "author" : "xcode" 11 | } 12 | } -------------------------------------------------------------------------------- /AutoPopupMenuControllerDemo/AutoPopupMenuControllerDemo/Assets.xcassets/Image.imageset/yy.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cxa/MenuItemKit/365321523300be357dd0665cfe048c4074203355/AutoPopupMenuControllerDemo/AutoPopupMenuControllerDemo/Assets.xcassets/Image.imageset/yy.pdf -------------------------------------------------------------------------------- /AutoPopupMenuControllerDemo/AutoPopupMenuControllerDemo/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 | -------------------------------------------------------------------------------- /AutoPopupMenuControllerDemo/AutoPopupMenuControllerDemo/Base.lproj/Main.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 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | -------------------------------------------------------------------------------- /AutoPopupMenuControllerDemo/AutoPopupMenuControllerDemo/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 | APPL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | 1 21 | LSRequiresIPhoneOS 22 | 23 | UILaunchStoryboardName 24 | LaunchScreen 25 | UIMainStoryboardFile 26 | Main 27 | UIRequiredDeviceCapabilities 28 | 29 | armv7 30 | 31 | UISupportedInterfaceOrientations 32 | 33 | UIInterfaceOrientationPortrait 34 | UIInterfaceOrientationLandscapeLeft 35 | UIInterfaceOrientationLandscapeRight 36 | 37 | UISupportedInterfaceOrientations~ipad 38 | 39 | UIInterfaceOrientationPortrait 40 | UIInterfaceOrientationPortraitUpsideDown 41 | UIInterfaceOrientationLandscapeLeft 42 | UIInterfaceOrientationLandscapeRight 43 | 44 | 45 | 46 | -------------------------------------------------------------------------------- /AutoPopupMenuControllerDemo/AutoPopupMenuControllerDemo/ViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.swift 3 | // AutoPopupMenuControllerDemo 4 | // 5 | // Created by CHEN Xian-an on 25/02/2018. 6 | // Copyright © 2018 Neo Xian-an CHEN. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | import MenuItemKit 11 | 12 | class ViewController: UIViewController { 13 | @IBOutlet weak var textView: UITextView! 14 | 15 | var showsColorItem = false 16 | 17 | override func viewDidLoad() { 18 | super.viewDidLoad() 19 | let controller = UIMenuController.shared 20 | let textItem = UIMenuItem(title: "Toggle Color Item") { [weak self] _ in 21 | self?.showAlertWithTitle("Toggle item tapped") 22 | self?.showsColorItem = !(self?.showsColorItem ?? true) 23 | } 24 | 25 | let image = UIImage(named: "Image") 26 | let imageItem = UIMenuItem(title: "Image", image: image) { [weak self] _ in 27 | self?.showAlertWithTitle("image item tapped") 28 | } 29 | 30 | let colorImage = UIImage(named: "ColorImage") 31 | let colorImageItem = UIMenuItem(title: "ColorImage", image: colorImage) { [weak self] _ in 32 | self?.showAlertWithTitle("color image item tapped") 33 | } 34 | 35 | controller.menuItems = [textItem, imageItem, colorImageItem] 36 | UIMenuController.installTo(responder: textView) { action, `default` in 37 | if action == colorImageItem.action { return self.showsColorItem } 38 | return UIMenuItem.isMenuItemKitSelector(action) 39 | } 40 | 41 | textView.becomeFirstResponder() 42 | } 43 | 44 | func showAlertWithTitle(_ title: String) { 45 | let alertVC = UIAlertController(title: title, message: nil, preferredStyle: .alert) 46 | alertVC.addAction(UIAlertAction(title: "Dismiss", style: .cancel, handler: { _ in })) 47 | present(alertVC, animated: true, completion: nil) 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /Demo-ObjC/Demo-ObjC.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | E0EFAEBA1C4AC6A000334D78 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = E0EFAEB91C4AC6A000334D78 /* main.m */; }; 11 | E0EFAEBD1C4AC6A000334D78 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = E0EFAEBC1C4AC6A000334D78 /* AppDelegate.m */; }; 12 | E0EFAEC01C4AC6A000334D78 /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = E0EFAEBF1C4AC6A000334D78 /* ViewController.m */; }; 13 | E0EFAED81C4AC6BB00334D78 /* MenuItemKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = E0EFAED51C4AC6B400334D78 /* MenuItemKit.framework */; }; 14 | E0EFAED91C4AC6BB00334D78 /* MenuItemKit.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = E0EFAED51C4AC6B400334D78 /* MenuItemKit.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; 15 | E0EFAEE11C4AC6E200334D78 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = E0EFAEDD1C4AC6E200334D78 /* LaunchScreen.storyboard */; }; 16 | E0EFAEE41C4AC6EE00334D78 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = E0EFAEE31C4AC6EE00334D78 /* Assets.xcassets */; }; 17 | E0EFAEE81C4AC9AD00334D78 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = E0EFAEE61C4AC9AD00334D78 /* Main.storyboard */; }; 18 | /* End PBXBuildFile section */ 19 | 20 | /* Begin PBXContainerItemProxy section */ 21 | E0EFAED41C4AC6B400334D78 /* PBXContainerItemProxy */ = { 22 | isa = PBXContainerItemProxy; 23 | containerPortal = E0EFAECF1C4AC6B400334D78 /* MenuItemKit.xcodeproj */; 24 | proxyType = 2; 25 | remoteGlobalIDString = E0EFAE4A1C49F99300334D78; 26 | remoteInfo = MenuItemKit; 27 | }; 28 | E0EFAEDA1C4AC6BB00334D78 /* PBXContainerItemProxy */ = { 29 | isa = PBXContainerItemProxy; 30 | containerPortal = E0EFAECF1C4AC6B400334D78 /* MenuItemKit.xcodeproj */; 31 | proxyType = 1; 32 | remoteGlobalIDString = E0EFAE491C49F99300334D78; 33 | remoteInfo = MenuItemKit; 34 | }; 35 | /* End PBXContainerItemProxy section */ 36 | 37 | /* Begin PBXCopyFilesBuildPhase section */ 38 | E0EFAEDC1C4AC6BB00334D78 /* Embed Frameworks */ = { 39 | isa = PBXCopyFilesBuildPhase; 40 | buildActionMask = 2147483647; 41 | dstPath = ""; 42 | dstSubfolderSpec = 10; 43 | files = ( 44 | E0EFAED91C4AC6BB00334D78 /* MenuItemKit.framework in Embed Frameworks */, 45 | ); 46 | name = "Embed Frameworks"; 47 | runOnlyForDeploymentPostprocessing = 0; 48 | }; 49 | /* End PBXCopyFilesBuildPhase section */ 50 | 51 | /* Begin PBXFileReference section */ 52 | E0EFAEB51C4AC6A000334D78 /* MenuItemKit-ObjC.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "MenuItemKit-ObjC.app"; sourceTree = BUILT_PRODUCTS_DIR; }; 53 | E0EFAEB91C4AC6A000334D78 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; 54 | E0EFAEBB1C4AC6A000334D78 /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; 55 | E0EFAEBC1C4AC6A000334D78 /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; }; 56 | E0EFAEBE1C4AC6A000334D78 /* ViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ViewController.h; sourceTree = ""; }; 57 | E0EFAEBF1C4AC6A000334D78 /* ViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ViewController.m; sourceTree = ""; }; 58 | E0EFAEC91C4AC6A000334D78 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 59 | E0EFAECF1C4AC6B400334D78 /* MenuItemKit.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = MenuItemKit.xcodeproj; path = ../MenuItemKit.xcodeproj; sourceTree = ""; }; 60 | E0EFAEDE1C4AC6E200334D78 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = ../../Demo/Demo/Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 61 | E0EFAEE31C4AC6EE00334D78 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; name = Assets.xcassets; path = ../../Demo/Demo/Assets.xcassets; sourceTree = ""; }; 62 | E0EFAEE71C4AC9AD00334D78 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 63 | /* End PBXFileReference section */ 64 | 65 | /* Begin PBXFrameworksBuildPhase section */ 66 | E0EFAEB21C4AC6A000334D78 /* Frameworks */ = { 67 | isa = PBXFrameworksBuildPhase; 68 | buildActionMask = 2147483647; 69 | files = ( 70 | E0EFAED81C4AC6BB00334D78 /* MenuItemKit.framework in Frameworks */, 71 | ); 72 | runOnlyForDeploymentPostprocessing = 0; 73 | }; 74 | /* End PBXFrameworksBuildPhase section */ 75 | 76 | /* Begin PBXGroup section */ 77 | E0EFAEAC1C4AC6A000334D78 = { 78 | isa = PBXGroup; 79 | children = ( 80 | E0EFAECF1C4AC6B400334D78 /* MenuItemKit.xcodeproj */, 81 | E0EFAEB71C4AC6A000334D78 /* Demo-ObjC */, 82 | E0EFAEB61C4AC6A000334D78 /* Products */, 83 | ); 84 | sourceTree = ""; 85 | }; 86 | E0EFAEB61C4AC6A000334D78 /* Products */ = { 87 | isa = PBXGroup; 88 | children = ( 89 | E0EFAEB51C4AC6A000334D78 /* MenuItemKit-ObjC.app */, 90 | ); 91 | name = Products; 92 | sourceTree = ""; 93 | }; 94 | E0EFAEB71C4AC6A000334D78 /* Demo-ObjC */ = { 95 | isa = PBXGroup; 96 | children = ( 97 | E0EFAEBB1C4AC6A000334D78 /* AppDelegate.h */, 98 | E0EFAEBC1C4AC6A000334D78 /* AppDelegate.m */, 99 | E0EFAEBE1C4AC6A000334D78 /* ViewController.h */, 100 | E0EFAEBF1C4AC6A000334D78 /* ViewController.m */, 101 | E0EFAEE31C4AC6EE00334D78 /* Assets.xcassets */, 102 | E0EFAEDD1C4AC6E200334D78 /* LaunchScreen.storyboard */, 103 | E0EFAEE61C4AC9AD00334D78 /* Main.storyboard */, 104 | E0EFAEC91C4AC6A000334D78 /* Info.plist */, 105 | E0EFAEB81C4AC6A000334D78 /* Supporting Files */, 106 | ); 107 | path = "Demo-ObjC"; 108 | sourceTree = ""; 109 | }; 110 | E0EFAEB81C4AC6A000334D78 /* Supporting Files */ = { 111 | isa = PBXGroup; 112 | children = ( 113 | E0EFAEB91C4AC6A000334D78 /* main.m */, 114 | ); 115 | name = "Supporting Files"; 116 | sourceTree = ""; 117 | }; 118 | E0EFAED01C4AC6B400334D78 /* Products */ = { 119 | isa = PBXGroup; 120 | children = ( 121 | E0EFAED51C4AC6B400334D78 /* MenuItemKit.framework */, 122 | ); 123 | name = Products; 124 | sourceTree = ""; 125 | }; 126 | /* End PBXGroup section */ 127 | 128 | /* Begin PBXNativeTarget section */ 129 | E0EFAEB41C4AC6A000334D78 /* MenuItemKit-ObjC */ = { 130 | isa = PBXNativeTarget; 131 | buildConfigurationList = E0EFAECC1C4AC6A000334D78 /* Build configuration list for PBXNativeTarget "MenuItemKit-ObjC" */; 132 | buildPhases = ( 133 | E0EFAEB11C4AC6A000334D78 /* Sources */, 134 | E0EFAEB21C4AC6A000334D78 /* Frameworks */, 135 | E0EFAEB31C4AC6A000334D78 /* Resources */, 136 | E0EFAEDC1C4AC6BB00334D78 /* Embed Frameworks */, 137 | ); 138 | buildRules = ( 139 | ); 140 | dependencies = ( 141 | E0EFAEDB1C4AC6BB00334D78 /* PBXTargetDependency */, 142 | ); 143 | name = "MenuItemKit-ObjC"; 144 | productName = "Demo-ObjC"; 145 | productReference = E0EFAEB51C4AC6A000334D78 /* MenuItemKit-ObjC.app */; 146 | productType = "com.apple.product-type.application"; 147 | }; 148 | /* End PBXNativeTarget section */ 149 | 150 | /* Begin PBXProject section */ 151 | E0EFAEAD1C4AC6A000334D78 /* Project object */ = { 152 | isa = PBXProject; 153 | attributes = { 154 | LastUpgradeCheck = 1200; 155 | ORGANIZATIONNAME = lazyapps; 156 | TargetAttributes = { 157 | E0EFAEB41C4AC6A000334D78 = { 158 | CreatedOnToolsVersion = 7.3; 159 | }; 160 | }; 161 | }; 162 | buildConfigurationList = E0EFAEB01C4AC6A000334D78 /* Build configuration list for PBXProject "Demo-ObjC" */; 163 | compatibilityVersion = "Xcode 3.2"; 164 | developmentRegion = en; 165 | hasScannedForEncodings = 0; 166 | knownRegions = ( 167 | en, 168 | Base, 169 | ); 170 | mainGroup = E0EFAEAC1C4AC6A000334D78; 171 | productRefGroup = E0EFAEB61C4AC6A000334D78 /* Products */; 172 | projectDirPath = ""; 173 | projectReferences = ( 174 | { 175 | ProductGroup = E0EFAED01C4AC6B400334D78 /* Products */; 176 | ProjectRef = E0EFAECF1C4AC6B400334D78 /* MenuItemKit.xcodeproj */; 177 | }, 178 | ); 179 | projectRoot = ""; 180 | targets = ( 181 | E0EFAEB41C4AC6A000334D78 /* MenuItemKit-ObjC */, 182 | ); 183 | }; 184 | /* End PBXProject section */ 185 | 186 | /* Begin PBXReferenceProxy section */ 187 | E0EFAED51C4AC6B400334D78 /* MenuItemKit.framework */ = { 188 | isa = PBXReferenceProxy; 189 | fileType = wrapper.framework; 190 | path = MenuItemKit.framework; 191 | remoteRef = E0EFAED41C4AC6B400334D78 /* PBXContainerItemProxy */; 192 | sourceTree = BUILT_PRODUCTS_DIR; 193 | }; 194 | /* End PBXReferenceProxy section */ 195 | 196 | /* Begin PBXResourcesBuildPhase section */ 197 | E0EFAEB31C4AC6A000334D78 /* Resources */ = { 198 | isa = PBXResourcesBuildPhase; 199 | buildActionMask = 2147483647; 200 | files = ( 201 | E0EFAEE81C4AC9AD00334D78 /* Main.storyboard in Resources */, 202 | E0EFAEE41C4AC6EE00334D78 /* Assets.xcassets in Resources */, 203 | E0EFAEE11C4AC6E200334D78 /* LaunchScreen.storyboard in Resources */, 204 | ); 205 | runOnlyForDeploymentPostprocessing = 0; 206 | }; 207 | /* End PBXResourcesBuildPhase section */ 208 | 209 | /* Begin PBXSourcesBuildPhase section */ 210 | E0EFAEB11C4AC6A000334D78 /* Sources */ = { 211 | isa = PBXSourcesBuildPhase; 212 | buildActionMask = 2147483647; 213 | files = ( 214 | E0EFAEC01C4AC6A000334D78 /* ViewController.m in Sources */, 215 | E0EFAEBD1C4AC6A000334D78 /* AppDelegate.m in Sources */, 216 | E0EFAEBA1C4AC6A000334D78 /* main.m in Sources */, 217 | ); 218 | runOnlyForDeploymentPostprocessing = 0; 219 | }; 220 | /* End PBXSourcesBuildPhase section */ 221 | 222 | /* Begin PBXTargetDependency section */ 223 | E0EFAEDB1C4AC6BB00334D78 /* PBXTargetDependency */ = { 224 | isa = PBXTargetDependency; 225 | name = MenuItemKit; 226 | targetProxy = E0EFAEDA1C4AC6BB00334D78 /* PBXContainerItemProxy */; 227 | }; 228 | /* End PBXTargetDependency section */ 229 | 230 | /* Begin PBXVariantGroup section */ 231 | E0EFAEDD1C4AC6E200334D78 /* LaunchScreen.storyboard */ = { 232 | isa = PBXVariantGroup; 233 | children = ( 234 | E0EFAEDE1C4AC6E200334D78 /* Base */, 235 | ); 236 | name = LaunchScreen.storyboard; 237 | sourceTree = ""; 238 | }; 239 | E0EFAEE61C4AC9AD00334D78 /* Main.storyboard */ = { 240 | isa = PBXVariantGroup; 241 | children = ( 242 | E0EFAEE71C4AC9AD00334D78 /* Base */, 243 | ); 244 | name = Main.storyboard; 245 | sourceTree = ""; 246 | }; 247 | /* End PBXVariantGroup section */ 248 | 249 | /* Begin XCBuildConfiguration section */ 250 | E0EFAECA1C4AC6A000334D78 /* Debug */ = { 251 | isa = XCBuildConfiguration; 252 | buildSettings = { 253 | ALWAYS_SEARCH_USER_PATHS = NO; 254 | CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES; 255 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 256 | CLANG_CXX_LIBRARY = "libc++"; 257 | CLANG_ENABLE_MODULES = YES; 258 | CLANG_ENABLE_OBJC_ARC = YES; 259 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 260 | CLANG_WARN_BOOL_CONVERSION = YES; 261 | CLANG_WARN_COMMA = YES; 262 | CLANG_WARN_CONSTANT_CONVERSION = YES; 263 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 264 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 265 | CLANG_WARN_EMPTY_BODY = YES; 266 | CLANG_WARN_ENUM_CONVERSION = YES; 267 | CLANG_WARN_INFINITE_RECURSION = YES; 268 | CLANG_WARN_INT_CONVERSION = YES; 269 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 270 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 271 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 272 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 273 | CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; 274 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 275 | CLANG_WARN_STRICT_PROTOTYPES = YES; 276 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 277 | CLANG_WARN_UNREACHABLE_CODE = YES; 278 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 279 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 280 | COPY_PHASE_STRIP = NO; 281 | DEBUG_INFORMATION_FORMAT = dwarf; 282 | ENABLE_STRICT_OBJC_MSGSEND = YES; 283 | ENABLE_TESTABILITY = YES; 284 | GCC_C_LANGUAGE_STANDARD = gnu99; 285 | GCC_DYNAMIC_NO_PIC = NO; 286 | GCC_NO_COMMON_BLOCKS = YES; 287 | GCC_OPTIMIZATION_LEVEL = 0; 288 | GCC_PREPROCESSOR_DEFINITIONS = ( 289 | "DEBUG=1", 290 | "$(inherited)", 291 | ); 292 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 293 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 294 | GCC_WARN_UNDECLARED_SELECTOR = YES; 295 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 296 | GCC_WARN_UNUSED_FUNCTION = YES; 297 | GCC_WARN_UNUSED_VARIABLE = YES; 298 | IPHONEOS_DEPLOYMENT_TARGET = 12.0; 299 | MTL_ENABLE_DEBUG_INFO = YES; 300 | ONLY_ACTIVE_ARCH = YES; 301 | SDKROOT = iphoneos; 302 | TARGETED_DEVICE_FAMILY = "1,2"; 303 | }; 304 | name = Debug; 305 | }; 306 | E0EFAECB1C4AC6A000334D78 /* Release */ = { 307 | isa = XCBuildConfiguration; 308 | buildSettings = { 309 | ALWAYS_SEARCH_USER_PATHS = NO; 310 | CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES; 311 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 312 | CLANG_CXX_LIBRARY = "libc++"; 313 | CLANG_ENABLE_MODULES = YES; 314 | CLANG_ENABLE_OBJC_ARC = YES; 315 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 316 | CLANG_WARN_BOOL_CONVERSION = YES; 317 | CLANG_WARN_COMMA = YES; 318 | CLANG_WARN_CONSTANT_CONVERSION = YES; 319 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 320 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 321 | CLANG_WARN_EMPTY_BODY = YES; 322 | CLANG_WARN_ENUM_CONVERSION = YES; 323 | CLANG_WARN_INFINITE_RECURSION = YES; 324 | CLANG_WARN_INT_CONVERSION = YES; 325 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 326 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 327 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 328 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 329 | CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; 330 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 331 | CLANG_WARN_STRICT_PROTOTYPES = YES; 332 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 333 | CLANG_WARN_UNREACHABLE_CODE = YES; 334 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 335 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 336 | COPY_PHASE_STRIP = NO; 337 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 338 | ENABLE_NS_ASSERTIONS = NO; 339 | ENABLE_STRICT_OBJC_MSGSEND = YES; 340 | GCC_C_LANGUAGE_STANDARD = gnu99; 341 | GCC_NO_COMMON_BLOCKS = YES; 342 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 343 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 344 | GCC_WARN_UNDECLARED_SELECTOR = YES; 345 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 346 | GCC_WARN_UNUSED_FUNCTION = YES; 347 | GCC_WARN_UNUSED_VARIABLE = YES; 348 | IPHONEOS_DEPLOYMENT_TARGET = 12.0; 349 | MTL_ENABLE_DEBUG_INFO = NO; 350 | SDKROOT = iphoneos; 351 | TARGETED_DEVICE_FAMILY = "1,2"; 352 | VALIDATE_PRODUCT = YES; 353 | }; 354 | name = Release; 355 | }; 356 | E0EFAECD1C4AC6A000334D78 /* Debug */ = { 357 | isa = XCBuildConfiguration; 358 | buildSettings = { 359 | ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; 360 | DEVELOPMENT_TEAM = ""; 361 | INFOPLIST_FILE = "Demo-ObjC/Info.plist"; 362 | IPHONEOS_DEPLOYMENT_TARGET = 12.0; 363 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 364 | PRODUCT_BUNDLE_IDENTIFIER = "com.lazyapps.MenuItemKitDemo-ObjC"; 365 | PRODUCT_NAME = "$(TARGET_NAME)"; 366 | }; 367 | name = Debug; 368 | }; 369 | E0EFAECE1C4AC6A000334D78 /* Release */ = { 370 | isa = XCBuildConfiguration; 371 | buildSettings = { 372 | ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; 373 | DEVELOPMENT_TEAM = ""; 374 | INFOPLIST_FILE = "Demo-ObjC/Info.plist"; 375 | IPHONEOS_DEPLOYMENT_TARGET = 12.0; 376 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 377 | PRODUCT_BUNDLE_IDENTIFIER = "com.lazyapps.MenuItemKitDemo-ObjC"; 378 | PRODUCT_NAME = "$(TARGET_NAME)"; 379 | }; 380 | name = Release; 381 | }; 382 | /* End XCBuildConfiguration section */ 383 | 384 | /* Begin XCConfigurationList section */ 385 | E0EFAEB01C4AC6A000334D78 /* Build configuration list for PBXProject "Demo-ObjC" */ = { 386 | isa = XCConfigurationList; 387 | buildConfigurations = ( 388 | E0EFAECA1C4AC6A000334D78 /* Debug */, 389 | E0EFAECB1C4AC6A000334D78 /* Release */, 390 | ); 391 | defaultConfigurationIsVisible = 0; 392 | defaultConfigurationName = Release; 393 | }; 394 | E0EFAECC1C4AC6A000334D78 /* Build configuration list for PBXNativeTarget "MenuItemKit-ObjC" */ = { 395 | isa = XCConfigurationList; 396 | buildConfigurations = ( 397 | E0EFAECD1C4AC6A000334D78 /* Debug */, 398 | E0EFAECE1C4AC6A000334D78 /* Release */, 399 | ); 400 | defaultConfigurationIsVisible = 0; 401 | defaultConfigurationName = Release; 402 | }; 403 | /* End XCConfigurationList section */ 404 | }; 405 | rootObject = E0EFAEAD1C4AC6A000334D78 /* Project object */; 406 | } 407 | -------------------------------------------------------------------------------- /Demo-ObjC/Demo-ObjC.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Demo-ObjC/Demo-ObjC/AppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.h 3 | // Demo-ObjC 4 | // 5 | // Created by CHEN Xian’an on 1/17/16. 6 | // Copyright © 2016 lazyapps. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface AppDelegate : UIResponder 12 | 13 | @property (strong, nonatomic) UIWindow *window; 14 | 15 | 16 | @end 17 | 18 | -------------------------------------------------------------------------------- /Demo-ObjC/Demo-ObjC/AppDelegate.m: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.m 3 | // Demo-ObjC 4 | // 5 | // Created by CHEN Xian’an on 1/17/16. 6 | // Copyright © 2016 lazyapps. All rights reserved. 7 | // 8 | 9 | #import "AppDelegate.h" 10 | 11 | @interface AppDelegate () 12 | 13 | @end 14 | 15 | @implementation AppDelegate 16 | 17 | 18 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { 19 | // Override point for customization after application launch. 20 | return YES; 21 | } 22 | 23 | - (void)applicationWillResignActive:(UIApplication *)application { 24 | // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. 25 | // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game. 26 | } 27 | 28 | - (void)applicationDidEnterBackground:(UIApplication *)application { 29 | // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. 30 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 31 | } 32 | 33 | - (void)applicationWillEnterForeground:(UIApplication *)application { 34 | // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background. 35 | } 36 | 37 | - (void)applicationDidBecomeActive:(UIApplication *)application { 38 | // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. 39 | } 40 | 41 | - (void)applicationWillTerminate:(UIApplication *)application { 42 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 43 | } 44 | 45 | @end 46 | -------------------------------------------------------------------------------- /Demo-ObjC/Demo-ObjC/Base.lproj/Main.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /Demo-ObjC/Demo-ObjC/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | APPL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | LSRequiresIPhoneOS 24 | 25 | UILaunchStoryboardName 26 | LaunchScreen 27 | UIMainStoryboardFile 28 | Main 29 | UIRequiredDeviceCapabilities 30 | 31 | armv7 32 | 33 | UISupportedInterfaceOrientations 34 | 35 | UIInterfaceOrientationPortrait 36 | UIInterfaceOrientationLandscapeLeft 37 | UIInterfaceOrientationLandscapeRight 38 | 39 | UISupportedInterfaceOrientations~ipad 40 | 41 | UIInterfaceOrientationPortrait 42 | UIInterfaceOrientationPortraitUpsideDown 43 | UIInterfaceOrientationLandscapeLeft 44 | UIInterfaceOrientationLandscapeRight 45 | 46 | 47 | 48 | -------------------------------------------------------------------------------- /Demo-ObjC/Demo-ObjC/ViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.h 3 | // Demo-ObjC 4 | // 5 | // Created by CHEN Xian’an on 1/17/16. 6 | // Copyright © 2016 lazyapps. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface ViewController : UIViewController 12 | 13 | 14 | @end 15 | 16 | -------------------------------------------------------------------------------- /Demo-ObjC/Demo-ObjC/ViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.m 3 | // Demo-ObjC 4 | // 5 | // Created by CHEN Xian’an on 1/17/16. 6 | // Copyright © 2016 lazyapps. All rights reserved. 7 | // 8 | 9 | #import "ViewController.h" 10 | @import MenuItemKit; 11 | 12 | @interface ViewController () 13 | 14 | @property (strong, nonatomic) IBOutlet UIButton *button; 15 | 16 | @end 17 | 18 | @implementation ViewController 19 | 20 | - (IBAction)tapButton:(id)sender 21 | { 22 | UIMenuController *controller = [UIMenuController sharedMenuController]; 23 | __weak typeof(self) _self = self; 24 | UIMenuItem *textItem = [[UIMenuItem alloc] mik_initWithTitle:@"Text" action:^(UIMenuItem *item) { 25 | [_self showAlertWithTitle:@"Text Item tapped"]; 26 | }]; 27 | 28 | UIImage *image = [UIImage imageNamed:@"Image"]; 29 | UIMenuItem *imageItem = [[UIMenuItem alloc] mik_initWithTitle:@"Image" image:image action:^(UIMenuItem *item) { 30 | [_self showAlertWithTitle:@"Image Item Tapped"]; 31 | }]; 32 | 33 | UIImage *colorImage = [UIImage imageNamed:@"ColorImage"]; 34 | UIMenuItem *colorImageItem = [[UIMenuItem alloc] mik_initWithTitle:@"Color Image" image:colorImage action:^(UIMenuItem *item) { 35 | [_self showAlertWithTitle:@"Color Image Item Tapped"]; 36 | }]; 37 | 38 | UIMenuItem *nextItem = [[UIMenuItem alloc] mik_initWithTitle:@"Show More Items..." action:^(UIMenuItem *item) { 39 | MenuItemAction action = ^(UIMenuItem *item) { [_self showAlertWithTitle:[item.title stringByAppendingString:@" Tapped"]]; }; 40 | UIMenuItem *item1 = [[UIMenuItem alloc] mik_initWithTitle:@"1" action:action]; 41 | UIMenuItem *item2 = [[UIMenuItem alloc] mik_initWithTitle:@"2" action:action]; 42 | UIMenuItem *item3 = [[UIMenuItem alloc] mik_initWithTitle:@"3" action:action]; 43 | controller.menuItems = @[item1, item2, item3]; 44 | if (@available(iOS 13.0, *)) { 45 | controller.menuVisible = YES; 46 | } else { 47 | [controller setMenuVisible:YES animated:YES]; 48 | } 49 | }]; 50 | 51 | controller.menuItems = @[textItem, imageItem, colorImageItem, nextItem]; 52 | if (@available(iOS 13.0, *)) { 53 | [controller showMenuFromView:self.button rect:self.button.bounds]; 54 | } else { 55 | [controller setTargetRect:self.button.bounds inView:self.button]; 56 | [controller setMenuVisible:YES animated:YES]; 57 | } 58 | } 59 | 60 | - (void)showAlertWithTitle:(NSString *)title 61 | { 62 | UIAlertController *alertVC = [UIAlertController alertControllerWithTitle:title message:nil preferredStyle:UIAlertControllerStyleAlert]; 63 | UIAlertAction *action = [UIAlertAction actionWithTitle:@"Dismiss" style:UIAlertActionStyleCancel handler:^(UIAlertAction *action) {}]; 64 | [alertVC addAction:action]; 65 | [self presentViewController:alertVC animated:YES completion:nil]; 66 | } 67 | 68 | @end 69 | -------------------------------------------------------------------------------- /Demo-ObjC/Demo-ObjC/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // Demo-ObjC 4 | // 5 | // Created by CHEN Xian’an on 1/17/16. 6 | // Copyright © 2016 lazyapps. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "AppDelegate.h" 11 | 12 | int main(int argc, char * argv[]) { 13 | @autoreleasepool { 14 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /Demo-SPM/Demo-SPM.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 52; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | E07A294E231429B5009676E0 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = E07A294A231429B5009676E0 /* Assets.xcassets */; }; 11 | E07A294F231429B5009676E0 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = E07A294B231429B5009676E0 /* AppDelegate.swift */; }; 12 | E07A2950231429B5009676E0 /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = E07A294C231429B5009676E0 /* ViewController.swift */; }; 13 | E07A2955231429D2009676E0 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = E07A2951231429D2009676E0 /* Main.storyboard */; }; 14 | E07A2956231429D2009676E0 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = E07A2953231429D2009676E0 /* LaunchScreen.storyboard */; }; 15 | E07A295E23142CC5009676E0 /* MenuItemKit in Frameworks */ = {isa = PBXBuildFile; productRef = E07A295D23142CC5009676E0 /* MenuItemKit */; }; 16 | /* End PBXBuildFile section */ 17 | 18 | /* Begin PBXFileReference section */ 19 | E07A293223142531009676E0 /* Demo-SPM.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "Demo-SPM.app"; sourceTree = BUILT_PRODUCTS_DIR; }; 20 | E07A2949231429B5009676E0 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = Info.plist; path = ../../Demo/Demo/Info.plist; sourceTree = ""; }; 21 | E07A294A231429B5009676E0 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; name = Assets.xcassets; path = ../../Demo/Demo/Assets.xcassets; sourceTree = ""; }; 22 | E07A294B231429B5009676E0 /* AppDelegate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = AppDelegate.swift; path = ../../Demo/Demo/AppDelegate.swift; sourceTree = ""; }; 23 | E07A294C231429B5009676E0 /* ViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = ViewController.swift; path = ../../Demo/Demo/ViewController.swift; sourceTree = ""; }; 24 | E07A2952231429D2009676E0 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = ../../Demo/Demo/Base.lproj/Main.storyboard; sourceTree = ""; }; 25 | E07A2954231429D2009676E0 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = ../../Demo/Demo/Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 26 | E07A295923142C7C009676E0 /* MenuItemKit */ = {isa = PBXFileReference; lastKnownFileType = folder; name = MenuItemKit; path = ..; sourceTree = ""; }; 27 | /* End PBXFileReference section */ 28 | 29 | /* Begin PBXFrameworksBuildPhase section */ 30 | E07A292F23142531009676E0 /* Frameworks */ = { 31 | isa = PBXFrameworksBuildPhase; 32 | buildActionMask = 2147483647; 33 | files = ( 34 | E07A295E23142CC5009676E0 /* MenuItemKit in Frameworks */, 35 | ); 36 | runOnlyForDeploymentPostprocessing = 0; 37 | }; 38 | /* End PBXFrameworksBuildPhase section */ 39 | 40 | /* Begin PBXGroup section */ 41 | E07A292923142531009676E0 = { 42 | isa = PBXGroup; 43 | children = ( 44 | E07A293423142531009676E0 /* Demo-SPM */, 45 | E07A293323142531009676E0 /* Products */, 46 | E07A295923142C7C009676E0 /* MenuItemKit */, 47 | E07A295A23142CB1009676E0 /* Frameworks */, 48 | ); 49 | sourceTree = ""; 50 | }; 51 | E07A293323142531009676E0 /* Products */ = { 52 | isa = PBXGroup; 53 | children = ( 54 | E07A293223142531009676E0 /* Demo-SPM.app */, 55 | ); 56 | name = Products; 57 | sourceTree = ""; 58 | }; 59 | E07A293423142531009676E0 /* Demo-SPM */ = { 60 | isa = PBXGroup; 61 | children = ( 62 | E07A294B231429B5009676E0 /* AppDelegate.swift */, 63 | E07A294A231429B5009676E0 /* Assets.xcassets */, 64 | E07A2949231429B5009676E0 /* Info.plist */, 65 | E07A294C231429B5009676E0 /* ViewController.swift */, 66 | E07A2953231429D2009676E0 /* LaunchScreen.storyboard */, 67 | E07A2951231429D2009676E0 /* Main.storyboard */, 68 | ); 69 | path = "Demo-SPM"; 70 | sourceTree = ""; 71 | }; 72 | E07A295A23142CB1009676E0 /* Frameworks */ = { 73 | isa = PBXGroup; 74 | children = ( 75 | ); 76 | name = Frameworks; 77 | sourceTree = ""; 78 | }; 79 | /* End PBXGroup section */ 80 | 81 | /* Begin PBXNativeTarget section */ 82 | E07A293123142531009676E0 /* Demo-SPM */ = { 83 | isa = PBXNativeTarget; 84 | buildConfigurationList = E07A294623142535009676E0 /* Build configuration list for PBXNativeTarget "Demo-SPM" */; 85 | buildPhases = ( 86 | E07A292E23142531009676E0 /* Sources */, 87 | E07A292F23142531009676E0 /* Frameworks */, 88 | E07A293023142531009676E0 /* Resources */, 89 | ); 90 | buildRules = ( 91 | ); 92 | dependencies = ( 93 | ); 94 | name = "Demo-SPM"; 95 | packageProductDependencies = ( 96 | E07A295D23142CC5009676E0 /* MenuItemKit */, 97 | ); 98 | productName = "Demo-SPM"; 99 | productReference = E07A293223142531009676E0 /* Demo-SPM.app */; 100 | productType = "com.apple.product-type.application"; 101 | }; 102 | /* End PBXNativeTarget section */ 103 | 104 | /* Begin PBXProject section */ 105 | E07A292A23142531009676E0 /* Project object */ = { 106 | isa = PBXProject; 107 | attributes = { 108 | LastSwiftUpdateCheck = 1100; 109 | LastUpgradeCheck = 1200; 110 | ORGANIZATIONNAME = realazy; 111 | TargetAttributes = { 112 | E07A293123142531009676E0 = { 113 | CreatedOnToolsVersion = 11.0; 114 | LastSwiftMigration = 1100; 115 | }; 116 | }; 117 | }; 118 | buildConfigurationList = E07A292D23142531009676E0 /* Build configuration list for PBXProject "Demo-SPM" */; 119 | compatibilityVersion = "Xcode 9.3"; 120 | developmentRegion = en; 121 | hasScannedForEncodings = 0; 122 | knownRegions = ( 123 | en, 124 | Base, 125 | ); 126 | mainGroup = E07A292923142531009676E0; 127 | productRefGroup = E07A293323142531009676E0 /* Products */; 128 | projectDirPath = ""; 129 | projectRoot = ""; 130 | targets = ( 131 | E07A293123142531009676E0 /* Demo-SPM */, 132 | ); 133 | }; 134 | /* End PBXProject section */ 135 | 136 | /* Begin PBXResourcesBuildPhase section */ 137 | E07A293023142531009676E0 /* Resources */ = { 138 | isa = PBXResourcesBuildPhase; 139 | buildActionMask = 2147483647; 140 | files = ( 141 | E07A2955231429D2009676E0 /* Main.storyboard in Resources */, 142 | E07A2956231429D2009676E0 /* LaunchScreen.storyboard in Resources */, 143 | E07A294E231429B5009676E0 /* Assets.xcassets in Resources */, 144 | ); 145 | runOnlyForDeploymentPostprocessing = 0; 146 | }; 147 | /* End PBXResourcesBuildPhase section */ 148 | 149 | /* Begin PBXSourcesBuildPhase section */ 150 | E07A292E23142531009676E0 /* Sources */ = { 151 | isa = PBXSourcesBuildPhase; 152 | buildActionMask = 2147483647; 153 | files = ( 154 | E07A2950231429B5009676E0 /* ViewController.swift in Sources */, 155 | E07A294F231429B5009676E0 /* AppDelegate.swift in Sources */, 156 | ); 157 | runOnlyForDeploymentPostprocessing = 0; 158 | }; 159 | /* End PBXSourcesBuildPhase section */ 160 | 161 | /* Begin PBXVariantGroup section */ 162 | E07A2951231429D2009676E0 /* Main.storyboard */ = { 163 | isa = PBXVariantGroup; 164 | children = ( 165 | E07A2952231429D2009676E0 /* Base */, 166 | ); 167 | name = Main.storyboard; 168 | sourceTree = ""; 169 | }; 170 | E07A2953231429D2009676E0 /* LaunchScreen.storyboard */ = { 171 | isa = PBXVariantGroup; 172 | children = ( 173 | E07A2954231429D2009676E0 /* Base */, 174 | ); 175 | name = LaunchScreen.storyboard; 176 | sourceTree = ""; 177 | }; 178 | /* End PBXVariantGroup section */ 179 | 180 | /* Begin XCBuildConfiguration section */ 181 | E07A294423142535009676E0 /* Debug */ = { 182 | isa = XCBuildConfiguration; 183 | buildSettings = { 184 | ALWAYS_SEARCH_USER_PATHS = NO; 185 | CLANG_ANALYZER_NONNULL = YES; 186 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 187 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; 188 | CLANG_CXX_LIBRARY = "libc++"; 189 | CLANG_ENABLE_MODULES = YES; 190 | CLANG_ENABLE_OBJC_ARC = YES; 191 | CLANG_ENABLE_OBJC_WEAK = YES; 192 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 193 | CLANG_WARN_BOOL_CONVERSION = YES; 194 | CLANG_WARN_COMMA = YES; 195 | CLANG_WARN_CONSTANT_CONVERSION = YES; 196 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 197 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 198 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 199 | CLANG_WARN_EMPTY_BODY = YES; 200 | CLANG_WARN_ENUM_CONVERSION = YES; 201 | CLANG_WARN_INFINITE_RECURSION = YES; 202 | CLANG_WARN_INT_CONVERSION = YES; 203 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 204 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 205 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 206 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 207 | CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; 208 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 209 | CLANG_WARN_STRICT_PROTOTYPES = YES; 210 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 211 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; 212 | CLANG_WARN_UNREACHABLE_CODE = YES; 213 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 214 | COPY_PHASE_STRIP = NO; 215 | DEBUG_INFORMATION_FORMAT = dwarf; 216 | ENABLE_STRICT_OBJC_MSGSEND = YES; 217 | ENABLE_TESTABILITY = YES; 218 | GCC_C_LANGUAGE_STANDARD = gnu11; 219 | GCC_DYNAMIC_NO_PIC = NO; 220 | GCC_NO_COMMON_BLOCKS = YES; 221 | GCC_OPTIMIZATION_LEVEL = 0; 222 | GCC_PREPROCESSOR_DEFINITIONS = ( 223 | "DEBUG=1", 224 | "$(inherited)", 225 | ); 226 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 227 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 228 | GCC_WARN_UNDECLARED_SELECTOR = YES; 229 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 230 | GCC_WARN_UNUSED_FUNCTION = YES; 231 | GCC_WARN_UNUSED_VARIABLE = YES; 232 | IPHONEOS_DEPLOYMENT_TARGET = 13.0; 233 | MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; 234 | MTL_FAST_MATH = YES; 235 | ONLY_ACTIVE_ARCH = YES; 236 | SDKROOT = iphoneos; 237 | SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; 238 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 239 | }; 240 | name = Debug; 241 | }; 242 | E07A294523142535009676E0 /* Release */ = { 243 | isa = XCBuildConfiguration; 244 | buildSettings = { 245 | ALWAYS_SEARCH_USER_PATHS = NO; 246 | CLANG_ANALYZER_NONNULL = YES; 247 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 248 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; 249 | CLANG_CXX_LIBRARY = "libc++"; 250 | CLANG_ENABLE_MODULES = YES; 251 | CLANG_ENABLE_OBJC_ARC = YES; 252 | CLANG_ENABLE_OBJC_WEAK = YES; 253 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 254 | CLANG_WARN_BOOL_CONVERSION = YES; 255 | CLANG_WARN_COMMA = YES; 256 | CLANG_WARN_CONSTANT_CONVERSION = YES; 257 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 258 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 259 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 260 | CLANG_WARN_EMPTY_BODY = YES; 261 | CLANG_WARN_ENUM_CONVERSION = YES; 262 | CLANG_WARN_INFINITE_RECURSION = YES; 263 | CLANG_WARN_INT_CONVERSION = YES; 264 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 265 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 266 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 267 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 268 | CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; 269 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 270 | CLANG_WARN_STRICT_PROTOTYPES = YES; 271 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 272 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; 273 | CLANG_WARN_UNREACHABLE_CODE = YES; 274 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 275 | COPY_PHASE_STRIP = NO; 276 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 277 | ENABLE_NS_ASSERTIONS = NO; 278 | ENABLE_STRICT_OBJC_MSGSEND = YES; 279 | GCC_C_LANGUAGE_STANDARD = gnu11; 280 | GCC_NO_COMMON_BLOCKS = YES; 281 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 282 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 283 | GCC_WARN_UNDECLARED_SELECTOR = YES; 284 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 285 | GCC_WARN_UNUSED_FUNCTION = YES; 286 | GCC_WARN_UNUSED_VARIABLE = YES; 287 | IPHONEOS_DEPLOYMENT_TARGET = 13.0; 288 | MTL_ENABLE_DEBUG_INFO = NO; 289 | MTL_FAST_MATH = YES; 290 | SDKROOT = iphoneos; 291 | SWIFT_COMPILATION_MODE = wholemodule; 292 | SWIFT_OPTIMIZATION_LEVEL = "-O"; 293 | VALIDATE_PRODUCT = YES; 294 | }; 295 | name = Release; 296 | }; 297 | E07A294723142535009676E0 /* Debug */ = { 298 | isa = XCBuildConfiguration; 299 | buildSettings = { 300 | CLANG_ENABLE_MODULES = YES; 301 | CODE_SIGN_STYLE = Automatic; 302 | INFOPLIST_FILE = "$(SRCROOT)/../Demo/Demo/Info.plist"; 303 | IPHONEOS_DEPLOYMENT_TARGET = 12.0; 304 | LD_RUNPATH_SEARCH_PATHS = ( 305 | "$(inherited)", 306 | "@executable_path/Frameworks", 307 | ); 308 | PRODUCT_BUNDLE_IDENTIFIER = "com.realazy.Demo-SPM"; 309 | PRODUCT_NAME = "$(TARGET_NAME)"; 310 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 311 | SWIFT_VERSION = 5.0; 312 | TARGETED_DEVICE_FAMILY = "1,2"; 313 | VALID_ARCHS = "$(ARCHS_STANDARD)"; 314 | }; 315 | name = Debug; 316 | }; 317 | E07A294823142535009676E0 /* Release */ = { 318 | isa = XCBuildConfiguration; 319 | buildSettings = { 320 | CLANG_ENABLE_MODULES = YES; 321 | CODE_SIGN_STYLE = Automatic; 322 | INFOPLIST_FILE = "$(SRCROOT)/../Demo/Demo/Info.plist"; 323 | IPHONEOS_DEPLOYMENT_TARGET = 12.0; 324 | LD_RUNPATH_SEARCH_PATHS = ( 325 | "$(inherited)", 326 | "@executable_path/Frameworks", 327 | ); 328 | PRODUCT_BUNDLE_IDENTIFIER = "com.realazy.Demo-SPM"; 329 | PRODUCT_NAME = "$(TARGET_NAME)"; 330 | SWIFT_VERSION = 5.0; 331 | TARGETED_DEVICE_FAMILY = "1,2"; 332 | VALID_ARCHS = "$(ARCHS_STANDARD)"; 333 | }; 334 | name = Release; 335 | }; 336 | /* End XCBuildConfiguration section */ 337 | 338 | /* Begin XCConfigurationList section */ 339 | E07A292D23142531009676E0 /* Build configuration list for PBXProject "Demo-SPM" */ = { 340 | isa = XCConfigurationList; 341 | buildConfigurations = ( 342 | E07A294423142535009676E0 /* Debug */, 343 | E07A294523142535009676E0 /* Release */, 344 | ); 345 | defaultConfigurationIsVisible = 0; 346 | defaultConfigurationName = Release; 347 | }; 348 | E07A294623142535009676E0 /* Build configuration list for PBXNativeTarget "Demo-SPM" */ = { 349 | isa = XCConfigurationList; 350 | buildConfigurations = ( 351 | E07A294723142535009676E0 /* Debug */, 352 | E07A294823142535009676E0 /* Release */, 353 | ); 354 | defaultConfigurationIsVisible = 0; 355 | defaultConfigurationName = Release; 356 | }; 357 | /* End XCConfigurationList section */ 358 | 359 | /* Begin XCSwiftPackageProductDependency section */ 360 | E07A295D23142CC5009676E0 /* MenuItemKit */ = { 361 | isa = XCSwiftPackageProductDependency; 362 | productName = MenuItemKit; 363 | }; 364 | /* End XCSwiftPackageProductDependency section */ 365 | }; 366 | rootObject = E07A292A23142531009676E0 /* Project object */; 367 | } 368 | -------------------------------------------------------------------------------- /Demo-SPM/Demo-SPM.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Demo-SPM/Demo-SPM/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | APPL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | LSRequiresIPhoneOS 24 | 25 | UILaunchStoryboardName 26 | LaunchScreen 27 | UIMainStoryboardFile 28 | Main 29 | UIRequiredDeviceCapabilities 30 | 31 | armv7 32 | 33 | UISupportedInterfaceOrientations 34 | 35 | UIInterfaceOrientationPortrait 36 | UIInterfaceOrientationLandscapeLeft 37 | UIInterfaceOrientationLandscapeRight 38 | 39 | UISupportedInterfaceOrientations~ipad 40 | 41 | UIInterfaceOrientationPortrait 42 | UIInterfaceOrientationPortraitUpsideDown 43 | UIInterfaceOrientationLandscapeLeft 44 | UIInterfaceOrientationLandscapeRight 45 | 46 | 47 | 48 | -------------------------------------------------------------------------------- /Demo/Demo.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | E0EFAE731C4A050000334D78 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = E0EFAE721C4A050000334D78 /* AppDelegate.swift */; }; 11 | E0EFAE751C4A050000334D78 /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = E0EFAE741C4A050000334D78 /* ViewController.swift */; }; 12 | E0EFAE781C4A050000334D78 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = E0EFAE761C4A050000334D78 /* Main.storyboard */; }; 13 | E0EFAE7A1C4A050000334D78 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = E0EFAE791C4A050000334D78 /* Assets.xcassets */; }; 14 | E0EFAE7D1C4A050000334D78 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = E0EFAE7B1C4A050000334D78 /* LaunchScreen.storyboard */; }; 15 | E0EFAE8D1C4A088400334D78 /* MenuItemKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = E0EFAE8A1C4A059700334D78 /* MenuItemKit.framework */; }; 16 | E0EFAE8E1C4A088400334D78 /* MenuItemKit.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = E0EFAE8A1C4A059700334D78 /* MenuItemKit.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; 17 | /* End PBXBuildFile section */ 18 | 19 | /* Begin PBXContainerItemProxy section */ 20 | E0EFAE891C4A059700334D78 /* PBXContainerItemProxy */ = { 21 | isa = PBXContainerItemProxy; 22 | containerPortal = E0EFAE841C4A059700334D78 /* MenuItemKit.xcodeproj */; 23 | proxyType = 2; 24 | remoteGlobalIDString = E0EFAE4A1C49F99300334D78; 25 | remoteInfo = MenuItemKit; 26 | }; 27 | E0EFAE8F1C4A088400334D78 /* PBXContainerItemProxy */ = { 28 | isa = PBXContainerItemProxy; 29 | containerPortal = E0EFAE841C4A059700334D78 /* MenuItemKit.xcodeproj */; 30 | proxyType = 1; 31 | remoteGlobalIDString = E0EFAE491C49F99300334D78; 32 | remoteInfo = MenuItemKit; 33 | }; 34 | /* End PBXContainerItemProxy section */ 35 | 36 | /* Begin PBXCopyFilesBuildPhase section */ 37 | E0EFAE911C4A088400334D78 /* Embed Frameworks */ = { 38 | isa = PBXCopyFilesBuildPhase; 39 | buildActionMask = 2147483647; 40 | dstPath = ""; 41 | dstSubfolderSpec = 10; 42 | files = ( 43 | E0EFAE8E1C4A088400334D78 /* MenuItemKit.framework in Embed Frameworks */, 44 | ); 45 | name = "Embed Frameworks"; 46 | runOnlyForDeploymentPostprocessing = 0; 47 | }; 48 | /* End PBXCopyFilesBuildPhase section */ 49 | 50 | /* Begin PBXFileReference section */ 51 | E0EFAE6F1C4A050000334D78 /* MenuItemKit-Swift.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "MenuItemKit-Swift.app"; sourceTree = BUILT_PRODUCTS_DIR; }; 52 | E0EFAE721C4A050000334D78 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 53 | E0EFAE741C4A050000334D78 /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = ""; }; 54 | E0EFAE771C4A050000334D78 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 55 | E0EFAE791C4A050000334D78 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 56 | E0EFAE7C1C4A050000334D78 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 57 | E0EFAE7E1C4A050000334D78 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 58 | E0EFAE841C4A059700334D78 /* MenuItemKit.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = MenuItemKit.xcodeproj; path = ../MenuItemKit.xcodeproj; sourceTree = ""; }; 59 | /* End PBXFileReference section */ 60 | 61 | /* Begin PBXFrameworksBuildPhase section */ 62 | E0EFAE6C1C4A050000334D78 /* Frameworks */ = { 63 | isa = PBXFrameworksBuildPhase; 64 | buildActionMask = 2147483647; 65 | files = ( 66 | E0EFAE8D1C4A088400334D78 /* MenuItemKit.framework in Frameworks */, 67 | ); 68 | runOnlyForDeploymentPostprocessing = 0; 69 | }; 70 | /* End PBXFrameworksBuildPhase section */ 71 | 72 | /* Begin PBXGroup section */ 73 | E0EFAE661C4A050000334D78 = { 74 | isa = PBXGroup; 75 | children = ( 76 | E0EFAE841C4A059700334D78 /* MenuItemKit.xcodeproj */, 77 | E0EFAE711C4A050000334D78 /* Demo */, 78 | E0EFAE701C4A050000334D78 /* Products */, 79 | ); 80 | sourceTree = ""; 81 | }; 82 | E0EFAE701C4A050000334D78 /* Products */ = { 83 | isa = PBXGroup; 84 | children = ( 85 | E0EFAE6F1C4A050000334D78 /* MenuItemKit-Swift.app */, 86 | ); 87 | name = Products; 88 | sourceTree = ""; 89 | }; 90 | E0EFAE711C4A050000334D78 /* Demo */ = { 91 | isa = PBXGroup; 92 | children = ( 93 | E0EFAE721C4A050000334D78 /* AppDelegate.swift */, 94 | E0EFAE741C4A050000334D78 /* ViewController.swift */, 95 | E0EFAE761C4A050000334D78 /* Main.storyboard */, 96 | E0EFAE791C4A050000334D78 /* Assets.xcassets */, 97 | E0EFAE7B1C4A050000334D78 /* LaunchScreen.storyboard */, 98 | E0EFAE7E1C4A050000334D78 /* Info.plist */, 99 | ); 100 | path = Demo; 101 | sourceTree = ""; 102 | }; 103 | E0EFAE851C4A059700334D78 /* Products */ = { 104 | isa = PBXGroup; 105 | children = ( 106 | E0EFAE8A1C4A059700334D78 /* MenuItemKit.framework */, 107 | ); 108 | name = Products; 109 | sourceTree = ""; 110 | }; 111 | /* End PBXGroup section */ 112 | 113 | /* Begin PBXNativeTarget section */ 114 | E0EFAE6E1C4A050000334D78 /* MenuItemKit-Swift */ = { 115 | isa = PBXNativeTarget; 116 | buildConfigurationList = E0EFAE811C4A050000334D78 /* Build configuration list for PBXNativeTarget "MenuItemKit-Swift" */; 117 | buildPhases = ( 118 | E0EFAE6B1C4A050000334D78 /* Sources */, 119 | E0EFAE6C1C4A050000334D78 /* Frameworks */, 120 | E0EFAE6D1C4A050000334D78 /* Resources */, 121 | E0EFAE911C4A088400334D78 /* Embed Frameworks */, 122 | ); 123 | buildRules = ( 124 | ); 125 | dependencies = ( 126 | E0EFAE901C4A088400334D78 /* PBXTargetDependency */, 127 | ); 128 | name = "MenuItemKit-Swift"; 129 | productName = Demo; 130 | productReference = E0EFAE6F1C4A050000334D78 /* MenuItemKit-Swift.app */; 131 | productType = "com.apple.product-type.application"; 132 | }; 133 | /* End PBXNativeTarget section */ 134 | 135 | /* Begin PBXProject section */ 136 | E0EFAE671C4A050000334D78 /* Project object */ = { 137 | isa = PBXProject; 138 | attributes = { 139 | LastSwiftUpdateCheck = 0730; 140 | LastUpgradeCheck = 1200; 141 | ORGANIZATIONNAME = lazyapps; 142 | TargetAttributes = { 143 | E0EFAE6E1C4A050000334D78 = { 144 | CreatedOnToolsVersion = 7.3; 145 | LastSwiftMigration = 1020; 146 | ProvisioningStyle = Automatic; 147 | }; 148 | }; 149 | }; 150 | buildConfigurationList = E0EFAE6A1C4A050000334D78 /* Build configuration list for PBXProject "Demo" */; 151 | compatibilityVersion = "Xcode 3.2"; 152 | developmentRegion = en; 153 | hasScannedForEncodings = 0; 154 | knownRegions = ( 155 | en, 156 | Base, 157 | ); 158 | mainGroup = E0EFAE661C4A050000334D78; 159 | productRefGroup = E0EFAE701C4A050000334D78 /* Products */; 160 | projectDirPath = ""; 161 | projectReferences = ( 162 | { 163 | ProductGroup = E0EFAE851C4A059700334D78 /* Products */; 164 | ProjectRef = E0EFAE841C4A059700334D78 /* MenuItemKit.xcodeproj */; 165 | }, 166 | ); 167 | projectRoot = ""; 168 | targets = ( 169 | E0EFAE6E1C4A050000334D78 /* MenuItemKit-Swift */, 170 | ); 171 | }; 172 | /* End PBXProject section */ 173 | 174 | /* Begin PBXReferenceProxy section */ 175 | E0EFAE8A1C4A059700334D78 /* MenuItemKit.framework */ = { 176 | isa = PBXReferenceProxy; 177 | fileType = wrapper.framework; 178 | path = MenuItemKit.framework; 179 | remoteRef = E0EFAE891C4A059700334D78 /* PBXContainerItemProxy */; 180 | sourceTree = BUILT_PRODUCTS_DIR; 181 | }; 182 | /* End PBXReferenceProxy section */ 183 | 184 | /* Begin PBXResourcesBuildPhase section */ 185 | E0EFAE6D1C4A050000334D78 /* Resources */ = { 186 | isa = PBXResourcesBuildPhase; 187 | buildActionMask = 2147483647; 188 | files = ( 189 | E0EFAE7D1C4A050000334D78 /* LaunchScreen.storyboard in Resources */, 190 | E0EFAE7A1C4A050000334D78 /* Assets.xcassets in Resources */, 191 | E0EFAE781C4A050000334D78 /* Main.storyboard in Resources */, 192 | ); 193 | runOnlyForDeploymentPostprocessing = 0; 194 | }; 195 | /* End PBXResourcesBuildPhase section */ 196 | 197 | /* Begin PBXSourcesBuildPhase section */ 198 | E0EFAE6B1C4A050000334D78 /* Sources */ = { 199 | isa = PBXSourcesBuildPhase; 200 | buildActionMask = 2147483647; 201 | files = ( 202 | E0EFAE751C4A050000334D78 /* ViewController.swift in Sources */, 203 | E0EFAE731C4A050000334D78 /* AppDelegate.swift in Sources */, 204 | ); 205 | runOnlyForDeploymentPostprocessing = 0; 206 | }; 207 | /* End PBXSourcesBuildPhase section */ 208 | 209 | /* Begin PBXTargetDependency section */ 210 | E0EFAE901C4A088400334D78 /* PBXTargetDependency */ = { 211 | isa = PBXTargetDependency; 212 | name = MenuItemKit; 213 | targetProxy = E0EFAE8F1C4A088400334D78 /* PBXContainerItemProxy */; 214 | }; 215 | /* End PBXTargetDependency section */ 216 | 217 | /* Begin PBXVariantGroup section */ 218 | E0EFAE761C4A050000334D78 /* Main.storyboard */ = { 219 | isa = PBXVariantGroup; 220 | children = ( 221 | E0EFAE771C4A050000334D78 /* Base */, 222 | ); 223 | name = Main.storyboard; 224 | sourceTree = ""; 225 | }; 226 | E0EFAE7B1C4A050000334D78 /* LaunchScreen.storyboard */ = { 227 | isa = PBXVariantGroup; 228 | children = ( 229 | E0EFAE7C1C4A050000334D78 /* Base */, 230 | ); 231 | name = LaunchScreen.storyboard; 232 | sourceTree = ""; 233 | }; 234 | /* End PBXVariantGroup section */ 235 | 236 | /* Begin XCBuildConfiguration section */ 237 | E0EFAE7F1C4A050000334D78 /* Debug */ = { 238 | isa = XCBuildConfiguration; 239 | buildSettings = { 240 | ALWAYS_SEARCH_USER_PATHS = NO; 241 | CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES; 242 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 243 | CLANG_CXX_LIBRARY = "libc++"; 244 | CLANG_ENABLE_MODULES = YES; 245 | CLANG_ENABLE_OBJC_ARC = YES; 246 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 247 | CLANG_WARN_BOOL_CONVERSION = YES; 248 | CLANG_WARN_COMMA = YES; 249 | CLANG_WARN_CONSTANT_CONVERSION = YES; 250 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 251 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 252 | CLANG_WARN_EMPTY_BODY = YES; 253 | CLANG_WARN_ENUM_CONVERSION = YES; 254 | CLANG_WARN_INFINITE_RECURSION = YES; 255 | CLANG_WARN_INT_CONVERSION = YES; 256 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 257 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 258 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 259 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 260 | CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; 261 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 262 | CLANG_WARN_STRICT_PROTOTYPES = YES; 263 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 264 | CLANG_WARN_UNREACHABLE_CODE = YES; 265 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 266 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 267 | COPY_PHASE_STRIP = NO; 268 | DEBUG_INFORMATION_FORMAT = dwarf; 269 | ENABLE_STRICT_OBJC_MSGSEND = YES; 270 | ENABLE_TESTABILITY = YES; 271 | GCC_C_LANGUAGE_STANDARD = gnu99; 272 | GCC_DYNAMIC_NO_PIC = NO; 273 | GCC_NO_COMMON_BLOCKS = YES; 274 | GCC_OPTIMIZATION_LEVEL = 0; 275 | GCC_PREPROCESSOR_DEFINITIONS = ( 276 | "DEBUG=1", 277 | "$(inherited)", 278 | ); 279 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 280 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 281 | GCC_WARN_UNDECLARED_SELECTOR = YES; 282 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 283 | GCC_WARN_UNUSED_FUNCTION = YES; 284 | GCC_WARN_UNUSED_VARIABLE = YES; 285 | IPHONEOS_DEPLOYMENT_TARGET = 12.0; 286 | MTL_ENABLE_DEBUG_INFO = YES; 287 | ONLY_ACTIVE_ARCH = YES; 288 | SDKROOT = iphoneos; 289 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 290 | SWIFT_SWIFT3_OBJC_INFERENCE = Default; 291 | SWIFT_VERSION = ""; 292 | TARGETED_DEVICE_FAMILY = "1,2"; 293 | }; 294 | name = Debug; 295 | }; 296 | E0EFAE801C4A050000334D78 /* Release */ = { 297 | isa = XCBuildConfiguration; 298 | buildSettings = { 299 | ALWAYS_SEARCH_USER_PATHS = NO; 300 | CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES; 301 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 302 | CLANG_CXX_LIBRARY = "libc++"; 303 | CLANG_ENABLE_MODULES = YES; 304 | CLANG_ENABLE_OBJC_ARC = YES; 305 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 306 | CLANG_WARN_BOOL_CONVERSION = YES; 307 | CLANG_WARN_COMMA = YES; 308 | CLANG_WARN_CONSTANT_CONVERSION = YES; 309 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 310 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 311 | CLANG_WARN_EMPTY_BODY = YES; 312 | CLANG_WARN_ENUM_CONVERSION = YES; 313 | CLANG_WARN_INFINITE_RECURSION = YES; 314 | CLANG_WARN_INT_CONVERSION = YES; 315 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 316 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 317 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 318 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 319 | CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; 320 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 321 | CLANG_WARN_STRICT_PROTOTYPES = YES; 322 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 323 | CLANG_WARN_UNREACHABLE_CODE = YES; 324 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 325 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 326 | COPY_PHASE_STRIP = NO; 327 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 328 | ENABLE_NS_ASSERTIONS = NO; 329 | ENABLE_STRICT_OBJC_MSGSEND = YES; 330 | GCC_C_LANGUAGE_STANDARD = gnu99; 331 | GCC_NO_COMMON_BLOCKS = YES; 332 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 333 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 334 | GCC_WARN_UNDECLARED_SELECTOR = YES; 335 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 336 | GCC_WARN_UNUSED_FUNCTION = YES; 337 | GCC_WARN_UNUSED_VARIABLE = YES; 338 | IPHONEOS_DEPLOYMENT_TARGET = 12.0; 339 | MTL_ENABLE_DEBUG_INFO = NO; 340 | SDKROOT = iphoneos; 341 | SWIFT_SWIFT3_OBJC_INFERENCE = Default; 342 | SWIFT_VERSION = ""; 343 | TARGETED_DEVICE_FAMILY = "1,2"; 344 | VALIDATE_PRODUCT = YES; 345 | }; 346 | name = Release; 347 | }; 348 | E0EFAE821C4A050000334D78 /* Debug */ = { 349 | isa = XCBuildConfiguration; 350 | buildSettings = { 351 | ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; 352 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 353 | DEVELOPMENT_TEAM = ""; 354 | INFOPLIST_FILE = Demo/Info.plist; 355 | IPHONEOS_DEPLOYMENT_TARGET = 12.0; 356 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 357 | PRODUCT_BUNDLE_IDENTIFIER = "com.lazyapps.MenuItemKitDemo-Swift"; 358 | PRODUCT_NAME = "$(TARGET_NAME)"; 359 | SWIFT_VERSION = 5.0; 360 | }; 361 | name = Debug; 362 | }; 363 | E0EFAE831C4A050000334D78 /* Release */ = { 364 | isa = XCBuildConfiguration; 365 | buildSettings = { 366 | ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; 367 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 368 | DEVELOPMENT_TEAM = ""; 369 | INFOPLIST_FILE = Demo/Info.plist; 370 | IPHONEOS_DEPLOYMENT_TARGET = 12.0; 371 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 372 | PRODUCT_BUNDLE_IDENTIFIER = "com.lazyapps.MenuItemKitDemo-Swift"; 373 | PRODUCT_NAME = "$(TARGET_NAME)"; 374 | SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; 375 | SWIFT_VERSION = 5.0; 376 | }; 377 | name = Release; 378 | }; 379 | /* End XCBuildConfiguration section */ 380 | 381 | /* Begin XCConfigurationList section */ 382 | E0EFAE6A1C4A050000334D78 /* Build configuration list for PBXProject "Demo" */ = { 383 | isa = XCConfigurationList; 384 | buildConfigurations = ( 385 | E0EFAE7F1C4A050000334D78 /* Debug */, 386 | E0EFAE801C4A050000334D78 /* Release */, 387 | ); 388 | defaultConfigurationIsVisible = 0; 389 | defaultConfigurationName = Release; 390 | }; 391 | E0EFAE811C4A050000334D78 /* Build configuration list for PBXNativeTarget "MenuItemKit-Swift" */ = { 392 | isa = XCConfigurationList; 393 | buildConfigurations = ( 394 | E0EFAE821C4A050000334D78 /* Debug */, 395 | E0EFAE831C4A050000334D78 /* Release */, 396 | ); 397 | defaultConfigurationIsVisible = 0; 398 | defaultConfigurationName = Release; 399 | }; 400 | /* End XCConfigurationList section */ 401 | }; 402 | rootObject = E0EFAE671C4A050000334D78 /* Project object */; 403 | } 404 | -------------------------------------------------------------------------------- /Demo/Demo.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Demo/Demo/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.swift 3 | // Demo 4 | // 5 | // Created by CHEN Xian’an on 1/16/16. 6 | // Copyright © 2016 lazyapps. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | @UIApplicationMain 12 | class AppDelegate: UIResponder, UIApplicationDelegate { 13 | var window: UIWindow? 14 | 15 | func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey : Any]? = nil) -> Bool { 16 | return true 17 | } 18 | 19 | func applicationWillResignActive(_ application: UIApplication) { 20 | // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. 21 | // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game. 22 | } 23 | 24 | func applicationDidEnterBackground(_ application: UIApplication) { 25 | // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. 26 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 27 | } 28 | 29 | func applicationWillEnterForeground(_ application: UIApplication) { 30 | // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background. 31 | } 32 | 33 | func applicationDidBecomeActive(_ application: UIApplication) { 34 | // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. 35 | } 36 | 37 | func applicationWillTerminate(_ application: UIApplication) { 38 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /Demo/Demo/Assets.xcassets/ColorImage.imageset/ColorImage.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cxa/MenuItemKit/365321523300be357dd0665cfe048c4074203355/Demo/Demo/Assets.xcassets/ColorImage.imageset/ColorImage.pdf -------------------------------------------------------------------------------- /Demo/Demo/Assets.xcassets/ColorImage.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "ColorImage.pdf" 6 | } 7 | ], 8 | "info" : { 9 | "version" : 1, 10 | "author" : "xcode" 11 | } 12 | } -------------------------------------------------------------------------------- /Demo/Demo/Assets.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "version" : 1, 4 | "author" : "xcode" 5 | } 6 | } -------------------------------------------------------------------------------- /Demo/Demo/Assets.xcassets/Image.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "yy.pdf" 6 | } 7 | ], 8 | "info" : { 9 | "version" : 1, 10 | "author" : "xcode" 11 | } 12 | } -------------------------------------------------------------------------------- /Demo/Demo/Assets.xcassets/Image.imageset/yy.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cxa/MenuItemKit/365321523300be357dd0665cfe048c4074203355/Demo/Demo/Assets.xcassets/Image.imageset/yy.pdf -------------------------------------------------------------------------------- /Demo/Demo/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 | 27 | 28 | 29 | 30 | -------------------------------------------------------------------------------- /Demo/Demo/Base.lproj/Main.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | -------------------------------------------------------------------------------- /Demo/Demo/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | APPL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | LSRequiresIPhoneOS 24 | 25 | UILaunchStoryboardName 26 | LaunchScreen 27 | UIMainStoryboardFile 28 | Main 29 | UIRequiredDeviceCapabilities 30 | 31 | armv7 32 | 33 | UISupportedInterfaceOrientations 34 | 35 | UIInterfaceOrientationPortrait 36 | UIInterfaceOrientationLandscapeLeft 37 | UIInterfaceOrientationLandscapeRight 38 | 39 | UISupportedInterfaceOrientations~ipad 40 | 41 | UIInterfaceOrientationPortrait 42 | UIInterfaceOrientationPortraitUpsideDown 43 | UIInterfaceOrientationLandscapeLeft 44 | UIInterfaceOrientationLandscapeRight 45 | 46 | 47 | 48 | -------------------------------------------------------------------------------- /Demo/Demo/ViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.swift 3 | // Demo 4 | // 5 | // Created by CHEN Xian’an on 1/16/16. 6 | // Copyright © 2016 lazyapps. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | import MenuItemKit 11 | 12 | class ViewController: UIViewController { 13 | @IBOutlet var button: UIButton! 14 | 15 | override func viewDidLoad() { 16 | super.viewDidLoad() 17 | button.addTarget(self, action: #selector(self.tapButton(_:)), for: .touchUpInside) 18 | } 19 | 20 | @objc func tapButton(_ sender: AnyObject?) { 21 | let controller = UIMenuController.shared 22 | let textItem = UIMenuItem(title: "Text") { [weak self] _ in 23 | self?.showAlertWithTitle("text item tapped") 24 | } 25 | 26 | let image = UIImage(named: "Image") 27 | let imageItem = UIMenuItem(title: "Image", image: image) { [weak self] _ in 28 | self?.showAlertWithTitle("image item tapped") 29 | } 30 | 31 | let colorImage = UIImage(named: "ColorImage") 32 | let colorImageItem = UIMenuItem(title: "ColorImage", image: colorImage) { [weak self] _ in 33 | self?.showAlertWithTitle("color image item tapped") 34 | } 35 | 36 | let nextItem = UIMenuItem(title: "Show More Items...") { _ in 37 | let action: MenuItemAction = { [weak self] in self?.showAlertWithTitle($0.title + " tapped") } 38 | let item1 = UIMenuItem(title: "1", action: action) 39 | let item2 = UIMenuItem(title: "2", action: action) 40 | let item3 = UIMenuItem(title: "3", action: action) 41 | controller.menuItems = [item1, item2, item3] 42 | if #available(iOS 13.0, *) { 43 | controller.isMenuVisible = true 44 | } else { 45 | controller.setMenuVisible(true, animated: true) 46 | } 47 | } 48 | 49 | controller.menuItems = [textItem, imageItem, colorImageItem, nextItem] 50 | if #available(iOS 13.0, *) { 51 | controller.showMenu(from: button, rect: button.bounds) 52 | } else { 53 | controller.setTargetRect(button.bounds, in: button) 54 | controller.setMenuVisible(true, animated: true) 55 | } 56 | } 57 | 58 | func showAlertWithTitle(_ title: String) { 59 | let alertVC = UIAlertController(title: title, message: nil, preferredStyle: .alert) 60 | alertVC.addAction(UIAlertAction(title: "Dismiss", style: .cancel, handler: { _ in })) 61 | present(alertVC, animated: true, completion: nil) 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2016 — Present CHEN Xian-an 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is furnished 8 | to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in all 11 | copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | THE SOFTWARE. 20 | -------------------------------------------------------------------------------- /MenuItemKit.podspec: -------------------------------------------------------------------------------- 1 | # coding: utf-8 2 | Pod::Spec.new do |s| 3 | s.name = "MenuItemKit" 4 | s.version = "4.0.1" 5 | s.summary = "MenuItemKit provides image and closure(block) support for UIMenuItem." 6 | s.author = "CHEN Xian’an " 7 | s.homepage = "https://github.com/cxa/MenuItemKit" 8 | s.license = 'MIT' 9 | s.source = { :git => 'https://github.com/cxa/MenuItemKit.git', :branch => "master", :tag => s.version.to_s } 10 | s.platform = :ios, '8.0' 11 | s.source_files = 'MenuItemKit/**/*.{h,m,swift}' 12 | s.requires_arc = true 13 | s.frameworks = 'UIKit' 14 | s.swift_version= "5.1" 15 | s.pod_target_xcconfig = { 16 | 'OTHER_SWIFT_FLAGS' => '-DNON_SPM', 17 | } 18 | end 19 | -------------------------------------------------------------------------------- /MenuItemKit.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | E0E372012314123300153746 /* Internals.swift in Sources */ = {isa = PBXBuildFile; fileRef = E0E371FB2314123300153746 /* Internals.swift */; }; 11 | E0E372022314123300153746 /* Swizzlings.swift in Sources */ = {isa = PBXBuildFile; fileRef = E0E371FC2314123300153746 /* Swizzlings.swift */; }; 12 | E0E372032314123300153746 /* UIMenuController.swift in Sources */ = {isa = PBXBuildFile; fileRef = E0E371FD2314123300153746 /* UIMenuController.swift */; }; 13 | E0E372042314123300153746 /* UIMenuItem.swift in Sources */ = {isa = PBXBuildFile; fileRef = E0E371FE2314123300153746 /* UIMenuItem.swift */; }; 14 | E0E372052314123300153746 /* Swizzlings.m in Sources */ = {isa = PBXBuildFile; fileRef = E0E372002314123300153746 /* Swizzlings.m */; }; 15 | E0E372082314193400153746 /* Headers.h in Headers */ = {isa = PBXBuildFile; fileRef = E0E372072314193400153746 /* Headers.h */; settings = {ATTRIBUTES = (Public, ); }; }; 16 | E0EFAE4E1C49F99300334D78 /* MenuItemKit.h in Headers */ = {isa = PBXBuildFile; fileRef = E0EFAE4D1C49F99300334D78 /* MenuItemKit.h */; settings = {ATTRIBUTES = (Public, ); }; }; 17 | /* End PBXBuildFile section */ 18 | 19 | /* Begin PBXFileReference section */ 20 | E0E371FB2314123300153746 /* Internals.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Internals.swift; sourceTree = ""; }; 21 | E0E371FC2314123300153746 /* Swizzlings.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Swizzlings.swift; sourceTree = ""; }; 22 | E0E371FD2314123300153746 /* UIMenuController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = UIMenuController.swift; sourceTree = ""; }; 23 | E0E371FE2314123300153746 /* UIMenuItem.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = UIMenuItem.swift; sourceTree = ""; }; 24 | E0E372002314123300153746 /* Swizzlings.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Swizzlings.m; sourceTree = ""; }; 25 | E0E372072314193400153746 /* Headers.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Headers.h; sourceTree = ""; }; 26 | E0EFAE4A1C49F99300334D78 /* MenuItemKit.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = MenuItemKit.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 27 | E0EFAE4D1C49F99300334D78 /* MenuItemKit.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MenuItemKit.h; sourceTree = ""; }; 28 | E0EFAE4F1C49F99300334D78 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 29 | /* End PBXFileReference section */ 30 | 31 | /* Begin PBXFrameworksBuildPhase section */ 32 | E0EFAE461C49F99300334D78 /* Frameworks */ = { 33 | isa = PBXFrameworksBuildPhase; 34 | buildActionMask = 2147483647; 35 | files = ( 36 | ); 37 | runOnlyForDeploymentPostprocessing = 0; 38 | }; 39 | /* End PBXFrameworksBuildPhase section */ 40 | 41 | /* Begin PBXGroup section */ 42 | E0E371FA2314123300153746 /* Swift */ = { 43 | isa = PBXGroup; 44 | children = ( 45 | E0E371FB2314123300153746 /* Internals.swift */, 46 | E0E371FC2314123300153746 /* Swizzlings.swift */, 47 | E0E371FD2314123300153746 /* UIMenuController.swift */, 48 | E0E371FE2314123300153746 /* UIMenuItem.swift */, 49 | ); 50 | path = Swift; 51 | sourceTree = ""; 52 | }; 53 | E0E371FF2314123300153746 /* ObjCSwizzlings */ = { 54 | isa = PBXGroup; 55 | children = ( 56 | E0E372062314193400153746 /* include */, 57 | E0E372002314123300153746 /* Swizzlings.m */, 58 | ); 59 | path = ObjCSwizzlings; 60 | sourceTree = ""; 61 | }; 62 | E0E372062314193400153746 /* include */ = { 63 | isa = PBXGroup; 64 | children = ( 65 | E0E372072314193400153746 /* Headers.h */, 66 | ); 67 | path = include; 68 | sourceTree = ""; 69 | }; 70 | E0EFAE401C49F99300334D78 = { 71 | isa = PBXGroup; 72 | children = ( 73 | E0EFAE4C1C49F99300334D78 /* MenuItemKit */, 74 | E0EFAE4B1C49F99300334D78 /* Products */, 75 | ); 76 | sourceTree = ""; 77 | }; 78 | E0EFAE4B1C49F99300334D78 /* Products */ = { 79 | isa = PBXGroup; 80 | children = ( 81 | E0EFAE4A1C49F99300334D78 /* MenuItemKit.framework */, 82 | ); 83 | name = Products; 84 | sourceTree = ""; 85 | }; 86 | E0EFAE4C1C49F99300334D78 /* MenuItemKit */ = { 87 | isa = PBXGroup; 88 | children = ( 89 | E0EFAE4F1C49F99300334D78 /* Info.plist */, 90 | E0EFAE4D1C49F99300334D78 /* MenuItemKit.h */, 91 | E0E371FF2314123300153746 /* ObjCSwizzlings */, 92 | E0E371FA2314123300153746 /* Swift */, 93 | ); 94 | path = MenuItemKit; 95 | sourceTree = ""; 96 | }; 97 | /* End PBXGroup section */ 98 | 99 | /* Begin PBXHeadersBuildPhase section */ 100 | E0EFAE471C49F99300334D78 /* Headers */ = { 101 | isa = PBXHeadersBuildPhase; 102 | buildActionMask = 2147483647; 103 | files = ( 104 | E0EFAE4E1C49F99300334D78 /* MenuItemKit.h in Headers */, 105 | E0E372082314193400153746 /* Headers.h in Headers */, 106 | ); 107 | runOnlyForDeploymentPostprocessing = 0; 108 | }; 109 | /* End PBXHeadersBuildPhase section */ 110 | 111 | /* Begin PBXNativeTarget section */ 112 | E0EFAE491C49F99300334D78 /* MenuItemKit */ = { 113 | isa = PBXNativeTarget; 114 | buildConfigurationList = E0EFAE5E1C49F99400334D78 /* Build configuration list for PBXNativeTarget "MenuItemKit" */; 115 | buildPhases = ( 116 | E0EFAE451C49F99300334D78 /* Sources */, 117 | E0EFAE461C49F99300334D78 /* Frameworks */, 118 | E0EFAE471C49F99300334D78 /* Headers */, 119 | E0EFAE481C49F99300334D78 /* Resources */, 120 | ); 121 | buildRules = ( 122 | ); 123 | dependencies = ( 124 | ); 125 | name = MenuItemKit; 126 | productName = MenuItemKit; 127 | productReference = E0EFAE4A1C49F99300334D78 /* MenuItemKit.framework */; 128 | productType = "com.apple.product-type.framework"; 129 | }; 130 | /* End PBXNativeTarget section */ 131 | 132 | /* Begin PBXProject section */ 133 | E0EFAE411C49F99300334D78 /* Project object */ = { 134 | isa = PBXProject; 135 | attributes = { 136 | LastSwiftUpdateCheck = 0730; 137 | LastUpgradeCheck = 1200; 138 | ORGANIZATIONNAME = lazyapps; 139 | TargetAttributes = { 140 | E0EFAE491C49F99300334D78 = { 141 | CreatedOnToolsVersion = 7.3; 142 | LastSwiftMigration = 1020; 143 | }; 144 | }; 145 | }; 146 | buildConfigurationList = E0EFAE441C49F99300334D78 /* Build configuration list for PBXProject "MenuItemKit" */; 147 | compatibilityVersion = "Xcode 3.2"; 148 | developmentRegion = en; 149 | hasScannedForEncodings = 0; 150 | knownRegions = ( 151 | en, 152 | Base, 153 | ); 154 | mainGroup = E0EFAE401C49F99300334D78; 155 | productRefGroup = E0EFAE4B1C49F99300334D78 /* Products */; 156 | projectDirPath = ""; 157 | projectRoot = ""; 158 | targets = ( 159 | E0EFAE491C49F99300334D78 /* MenuItemKit */, 160 | ); 161 | }; 162 | /* End PBXProject section */ 163 | 164 | /* Begin PBXResourcesBuildPhase section */ 165 | E0EFAE481C49F99300334D78 /* Resources */ = { 166 | isa = PBXResourcesBuildPhase; 167 | buildActionMask = 2147483647; 168 | files = ( 169 | ); 170 | runOnlyForDeploymentPostprocessing = 0; 171 | }; 172 | /* End PBXResourcesBuildPhase section */ 173 | 174 | /* Begin PBXSourcesBuildPhase section */ 175 | E0EFAE451C49F99300334D78 /* Sources */ = { 176 | isa = PBXSourcesBuildPhase; 177 | buildActionMask = 2147483647; 178 | files = ( 179 | E0E372032314123300153746 /* UIMenuController.swift in Sources */, 180 | E0E372042314123300153746 /* UIMenuItem.swift in Sources */, 181 | E0E372012314123300153746 /* Internals.swift in Sources */, 182 | E0E372052314123300153746 /* Swizzlings.m in Sources */, 183 | E0E372022314123300153746 /* Swizzlings.swift in Sources */, 184 | ); 185 | runOnlyForDeploymentPostprocessing = 0; 186 | }; 187 | /* End PBXSourcesBuildPhase section */ 188 | 189 | /* Begin XCBuildConfiguration section */ 190 | E0EFAE5C1C49F99400334D78 /* Debug */ = { 191 | isa = XCBuildConfiguration; 192 | buildSettings = { 193 | ALWAYS_SEARCH_USER_PATHS = NO; 194 | CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES; 195 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 196 | CLANG_CXX_LIBRARY = "libc++"; 197 | CLANG_ENABLE_MODULES = YES; 198 | CLANG_ENABLE_OBJC_ARC = YES; 199 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 200 | CLANG_WARN_BOOL_CONVERSION = YES; 201 | CLANG_WARN_COMMA = YES; 202 | CLANG_WARN_CONSTANT_CONVERSION = YES; 203 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 204 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 205 | CLANG_WARN_EMPTY_BODY = YES; 206 | CLANG_WARN_ENUM_CONVERSION = YES; 207 | CLANG_WARN_INFINITE_RECURSION = YES; 208 | CLANG_WARN_INT_CONVERSION = YES; 209 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 210 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 211 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 212 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 213 | CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; 214 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 215 | CLANG_WARN_STRICT_PROTOTYPES = YES; 216 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 217 | CLANG_WARN_UNREACHABLE_CODE = YES; 218 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 219 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 220 | COPY_PHASE_STRIP = NO; 221 | CURRENT_PROJECT_VERSION = 1; 222 | DEBUG_INFORMATION_FORMAT = dwarf; 223 | ENABLE_STRICT_OBJC_MSGSEND = YES; 224 | ENABLE_TESTABILITY = YES; 225 | GCC_C_LANGUAGE_STANDARD = gnu99; 226 | GCC_DYNAMIC_NO_PIC = NO; 227 | GCC_NO_COMMON_BLOCKS = YES; 228 | GCC_OPTIMIZATION_LEVEL = 0; 229 | GCC_PREPROCESSOR_DEFINITIONS = ( 230 | "DEBUG=1", 231 | "$(inherited)", 232 | ); 233 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 234 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 235 | GCC_WARN_UNDECLARED_SELECTOR = YES; 236 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 237 | GCC_WARN_UNUSED_FUNCTION = YES; 238 | GCC_WARN_UNUSED_VARIABLE = YES; 239 | IPHONEOS_DEPLOYMENT_TARGET = 12.0; 240 | MTL_ENABLE_DEBUG_INFO = YES; 241 | ONLY_ACTIVE_ARCH = YES; 242 | SDKROOT = iphoneos; 243 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 244 | SWIFT_SWIFT3_OBJC_INFERENCE = Default; 245 | SWIFT_VERSION = ""; 246 | TARGETED_DEVICE_FAMILY = "1,2"; 247 | VERSIONING_SYSTEM = "apple-generic"; 248 | VERSION_INFO_PREFIX = ""; 249 | }; 250 | name = Debug; 251 | }; 252 | E0EFAE5D1C49F99400334D78 /* Release */ = { 253 | isa = XCBuildConfiguration; 254 | buildSettings = { 255 | ALWAYS_SEARCH_USER_PATHS = NO; 256 | CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES; 257 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 258 | CLANG_CXX_LIBRARY = "libc++"; 259 | CLANG_ENABLE_MODULES = YES; 260 | CLANG_ENABLE_OBJC_ARC = YES; 261 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 262 | CLANG_WARN_BOOL_CONVERSION = YES; 263 | CLANG_WARN_COMMA = YES; 264 | CLANG_WARN_CONSTANT_CONVERSION = YES; 265 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 266 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 267 | CLANG_WARN_EMPTY_BODY = YES; 268 | CLANG_WARN_ENUM_CONVERSION = YES; 269 | CLANG_WARN_INFINITE_RECURSION = YES; 270 | CLANG_WARN_INT_CONVERSION = YES; 271 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 272 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 273 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 274 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 275 | CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; 276 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 277 | CLANG_WARN_STRICT_PROTOTYPES = YES; 278 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 279 | CLANG_WARN_UNREACHABLE_CODE = YES; 280 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 281 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 282 | COPY_PHASE_STRIP = NO; 283 | CURRENT_PROJECT_VERSION = 1; 284 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 285 | ENABLE_NS_ASSERTIONS = NO; 286 | ENABLE_STRICT_OBJC_MSGSEND = YES; 287 | GCC_C_LANGUAGE_STANDARD = gnu99; 288 | GCC_NO_COMMON_BLOCKS = YES; 289 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 290 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 291 | GCC_WARN_UNDECLARED_SELECTOR = YES; 292 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 293 | GCC_WARN_UNUSED_FUNCTION = YES; 294 | GCC_WARN_UNUSED_VARIABLE = YES; 295 | IPHONEOS_DEPLOYMENT_TARGET = 12.0; 296 | MTL_ENABLE_DEBUG_INFO = NO; 297 | SDKROOT = iphoneos; 298 | SWIFT_SWIFT3_OBJC_INFERENCE = Default; 299 | SWIFT_VERSION = ""; 300 | TARGETED_DEVICE_FAMILY = "1,2"; 301 | VALIDATE_PRODUCT = YES; 302 | VERSIONING_SYSTEM = "apple-generic"; 303 | VERSION_INFO_PREFIX = ""; 304 | }; 305 | name = Release; 306 | }; 307 | E0EFAE5F1C49F99400334D78 /* Debug */ = { 308 | isa = XCBuildConfiguration; 309 | buildSettings = { 310 | CLANG_ENABLE_MODULES = YES; 311 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = ""; 312 | DEFINES_MODULE = YES; 313 | DYLIB_COMPATIBILITY_VERSION = 1; 314 | DYLIB_CURRENT_VERSION = 1; 315 | DYLIB_INSTALL_NAME_BASE = "@rpath"; 316 | HEADER_SEARCH_PATHS = ""; 317 | INFOPLIST_FILE = MenuItemKit/Info.plist; 318 | INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; 319 | IPHONEOS_DEPLOYMENT_TARGET = 12.0; 320 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 321 | OTHER_SWIFT_FLAGS = "-DNON_SPM"; 322 | PRODUCT_BUNDLE_IDENTIFIER = com.lazyapps.MenuItemKit; 323 | PRODUCT_NAME = "$(TARGET_NAME)"; 324 | SKIP_INSTALL = YES; 325 | SWIFT_ACTIVE_COMPILATION_CONDITIONS = ""; 326 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 327 | SWIFT_VERSION = 5.0; 328 | VALID_ARCHS = "$(ARCHS_STANDARD)"; 329 | }; 330 | name = Debug; 331 | }; 332 | E0EFAE601C49F99400334D78 /* Release */ = { 333 | isa = XCBuildConfiguration; 334 | buildSettings = { 335 | CLANG_ENABLE_MODULES = YES; 336 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = ""; 337 | DEFINES_MODULE = YES; 338 | DYLIB_COMPATIBILITY_VERSION = 1; 339 | DYLIB_CURRENT_VERSION = 1; 340 | DYLIB_INSTALL_NAME_BASE = "@rpath"; 341 | HEADER_SEARCH_PATHS = ""; 342 | INFOPLIST_FILE = MenuItemKit/Info.plist; 343 | INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; 344 | IPHONEOS_DEPLOYMENT_TARGET = 12.0; 345 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 346 | OTHER_SWIFT_FLAGS = "-DNON_SPM"; 347 | PRODUCT_BUNDLE_IDENTIFIER = com.lazyapps.MenuItemKit; 348 | PRODUCT_NAME = "$(TARGET_NAME)"; 349 | SKIP_INSTALL = YES; 350 | SWIFT_ACTIVE_COMPILATION_CONDITIONS = ""; 351 | SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; 352 | SWIFT_VERSION = 5.0; 353 | VALID_ARCHS = "$(ARCHS_STANDARD)"; 354 | }; 355 | name = Release; 356 | }; 357 | /* End XCBuildConfiguration section */ 358 | 359 | /* Begin XCConfigurationList section */ 360 | E0EFAE441C49F99300334D78 /* Build configuration list for PBXProject "MenuItemKit" */ = { 361 | isa = XCConfigurationList; 362 | buildConfigurations = ( 363 | E0EFAE5C1C49F99400334D78 /* Debug */, 364 | E0EFAE5D1C49F99400334D78 /* Release */, 365 | ); 366 | defaultConfigurationIsVisible = 0; 367 | defaultConfigurationName = Release; 368 | }; 369 | E0EFAE5E1C49F99400334D78 /* Build configuration list for PBXNativeTarget "MenuItemKit" */ = { 370 | isa = XCConfigurationList; 371 | buildConfigurations = ( 372 | E0EFAE5F1C49F99400334D78 /* Debug */, 373 | E0EFAE601C49F99400334D78 /* Release */, 374 | ); 375 | defaultConfigurationIsVisible = 0; 376 | defaultConfigurationName = Release; 377 | }; 378 | /* End XCConfigurationList section */ 379 | }; 380 | rootObject = E0EFAE411C49F99300334D78 /* Project object */; 381 | } 382 | -------------------------------------------------------------------------------- /MenuItemKit.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /MenuItemKit.xcodeproj/xcshareddata/xcschemes/MenuItemKit.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 37 | 38 | 39 | 40 | 42 | 48 | 49 | 50 | 51 | 52 | 62 | 63 | 69 | 70 | 71 | 72 | 78 | 79 | 85 | 86 | 87 | 88 | 90 | 91 | 94 | 95 | 96 | -------------------------------------------------------------------------------- /MenuItemKit/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | FMWK 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | $(CURRENT_PROJECT_VERSION) 23 | NSPrincipalClass 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /MenuItemKit/MenuItemKit.h: -------------------------------------------------------------------------------- 1 | // 2 | // MenuItemKit.h 3 | // MenuItemKit 4 | // 5 | // Created by CHEN Xian’an on 1/16/16. 6 | // Copyright © 2016 lazyapps. All rights reserved. 7 | // 8 | 9 | #import 10 | #import 11 | 12 | //! Project version number for MenuItemKit. 13 | FOUNDATION_EXPORT double MenuItemKitVersionNumber; 14 | 15 | //! Project version string for MenuItemKit. 16 | FOUNDATION_EXPORT const unsigned char MenuItemKitVersionString[]; 17 | -------------------------------------------------------------------------------- /MenuItemKit/ObjCSwizzlings/Swizzlings.m: -------------------------------------------------------------------------------- 1 | // 2 | // Swizzlings.m 3 | // MenuItemKit 4 | // 5 | // Created by CHEN Xian’an on 1/17/16. 6 | // Copyright © 2016 lazyapps. All rights reserved. 7 | // 8 | 9 | @import UIKit; 10 | 11 | #define LOAD(klass) \ 12 | @implementation klass(MenuItemKit) \ 13 | + (void)load \ 14 | { \ 15 | static dispatch_once_t onceToken; \ 16 | dispatch_once(&onceToken, ^{ \ 17 | [self performSelector:NSSelectorFromString(@"_mik_load")]; \ 18 | }); \ 19 | } \ 20 | @end 21 | 22 | #pragma clang diagnostic push 23 | #pragma clang diagnostic ignored "-Warc-performSelector-leaks" 24 | LOAD(UIMenuController) 25 | LOAD(UILabel) 26 | LOAD(NSString) 27 | #pragma clang diagnostic pop 28 | 29 | @implementation NSObject (MenuItemKit) 30 | 31 | + (NSMethodSignature *)_mik_fakeSignature 32 | { 33 | return [NSMethodSignature signatureWithObjCTypes:"v@:@"]; 34 | } 35 | 36 | @end 37 | -------------------------------------------------------------------------------- /MenuItemKit/ObjCSwizzlings/include/Headers.h: -------------------------------------------------------------------------------- 1 | // 2 | // File.swift 3 | // 4 | // 5 | // Created by CHEN Xian-an on 2019/8/26. 6 | // 7 | 8 | #import 9 | 10 | typedef void (^MenuItemAction)(UIMenuItem * _Nonnull); 11 | -------------------------------------------------------------------------------- /MenuItemKit/Swift/Internals.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Internals.swift 3 | // MenuItemKit 4 | // 5 | // Created by CHEN Xian’an on 1/17/16. 6 | // Copyright © 2016 lazyapps. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | import ObjectiveC.runtime 11 | #if !NON_SPM 12 | import ObjCSwizzlings 13 | #endif 14 | 15 | let imageItemIdetifier = "\u{FEFF}\u{200B}" 16 | 17 | let blockIdentifierPrefix = "_menuitemkit_block_" 18 | 19 | func setNewIMPWithBlock(_ block: T, forSelector selector: Selector, toClass klass: AnyClass) { 20 | let method = class_getInstanceMethod(klass, selector) 21 | let imp = imp_implementationWithBlock(unsafeBitCast(block, to: AnyObject.self)) 22 | if !class_addMethod(klass, selector, imp, method_getTypeEncoding(method!)) { 23 | method_setImplementation(method!, imp) 24 | } 25 | } 26 | 27 | @nonobjc extension NSObject { 28 | var imageBox: Box { 29 | let key: StaticString = #function 30 | return associatedBoxForKey(key, initialValue: nil) 31 | } 32 | 33 | var actionBox: Box { 34 | let key: StaticString = #function 35 | return associatedBoxForKey(key, initialValue: nil) 36 | } 37 | 38 | var actionFilterBox: Box { 39 | let key: StaticString = #function 40 | return associatedBoxForKey(key, initialValue: nil) 41 | } 42 | 43 | func associatedBoxForKey(_ key: StaticString, initialValue: @autoclosure () -> T) -> Box { 44 | guard let box = objc_getAssociatedObject(self, key.utf8Start) as? Box else { 45 | let box = Box(initialValue()) 46 | objc_setAssociatedObject(self, key.utf8Start, box as AnyObject, .OBJC_ASSOCIATION_RETAIN_NONATOMIC) 47 | return box 48 | } 49 | 50 | return box 51 | } 52 | } 53 | 54 | // MARK: Box wrapper 55 | final class Box { 56 | var value: T 57 | 58 | init(_ val: T) { 59 | value = val 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /MenuItemKit/Swift/Swizzlings.swift: -------------------------------------------------------------------------------- 1 | // 2 | // UIMenuController.swift 3 | // MenuItemKit 4 | // 5 | // Created by CHEN Xian’an on 1/17/16. 6 | // Copyright © 2016 lazyapps. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | import ObjectiveC.runtime 11 | 12 | // This is inspired by https://github.com/steipete/PSMenuItem 13 | internal func swizzle(_ object: Any, shouldShowForAction: @escaping ActionFilter = { $1 }) { 14 | let cls: AnyClass? = object_getClass(object); 15 | let isClass = class_isMetaClass(cls); 16 | let klass: AnyClass = isClass ? object as! AnyClass : cls!; 17 | if !isClass, let nsobj = object as? NSObject { nsobj.actionFilterBox.value = shouldShowForAction } 18 | objc_sync_enter(klass) 19 | defer { objc_sync_exit(klass) } 20 | let key: StaticString = #function 21 | guard objc_getAssociatedObject(klass, key.utf8Start) == nil else { return } 22 | if true { 23 | // swizzle canBecomeFirstResponder 24 | let selector = #selector(getter: UIResponder.canBecomeFirstResponder) 25 | let block: @convention(block) (AnyObject) -> Bool = { _ in true } 26 | setNewIMPWithBlock(block, forSelector: selector, toClass: klass) 27 | } 28 | 29 | if true { 30 | // swizzle canPerformAction:withSender: 31 | let selector = #selector(UIResponder.canPerformAction(_:withSender:)) 32 | let origIMP = class_getMethodImplementation(klass, selector) 33 | typealias IMPType = @convention(c) (AnyObject, Selector, Selector, AnyObject) -> Bool 34 | let origIMPC = unsafeBitCast(origIMP, to: IMPType.self) 35 | let block: @convention(block) (AnyObject, Selector, AnyObject) -> Bool = { 36 | let `default` = UIMenuItem.isMenuItemKitSelector($1) ? true : origIMPC($0, selector, $1, $2) 37 | if let shouldShow = ($0 as? NSObject)?.actionFilterBox.value { return shouldShow($1, `default`) } 38 | return `default` 39 | } 40 | 41 | setNewIMPWithBlock(block, forSelector: selector, toClass: klass) 42 | } 43 | 44 | if true { 45 | // swizzle methodSignatureForSelector: 46 | let selector = NSSelectorFromString("methodSignatureForSelector:") 47 | let origIMP = class_getMethodImplementation(klass, selector) 48 | typealias IMPType = @convention(c) (AnyObject, Selector, Selector) -> AnyObject 49 | let origIMPC = unsafeBitCast(origIMP, to: IMPType.self) 50 | let block: @convention(block) (AnyObject, Selector) -> AnyObject = { 51 | if UIMenuItem.isMenuItemKitSelector($1) { 52 | // `NSMethodSignature` is not allowed in Swift, this is a workaround 53 | return NSObject.perform(NSSelectorFromString("_mik_fakeSignature")).takeUnretainedValue() 54 | } 55 | 56 | return origIMPC($0, selector, $1) 57 | } 58 | 59 | setNewIMPWithBlock(block, forSelector: selector, toClass: klass) 60 | } 61 | 62 | if true { 63 | // swizzle forwardInvocation: 64 | // `NSInvocation` is not allowed in Swift, so we just use AnyObject 65 | let selector = NSSelectorFromString("forwardInvocation:") 66 | let origIMP = class_getMethodImplementation(klass, selector) 67 | typealias IMPType = @convention(c) (AnyObject, Selector, AnyObject) -> Void 68 | let origIMPC = unsafeBitCast(origIMP, to: IMPType.self) 69 | let block: @convention(block) (AnyObject, AnyObject) -> Void = { 70 | if UIMenuItem.isMenuItemKitSelector($1.selector) { 71 | guard let item = UIMenuController.shared.findMenuItemBySelector($1.selector) else { return } 72 | item.actionBox.value?(item) 73 | } else { 74 | origIMPC($0, selector, $1) 75 | } 76 | } 77 | 78 | setNewIMPWithBlock(block, forSelector: selector, toClass: klass) 79 | } 80 | 81 | objc_setAssociatedObject(klass, key.utf8Start, true, .OBJC_ASSOCIATION_RETAIN_NONATOMIC) 82 | } 83 | 84 | private extension UIMenuController { 85 | @objc class func _mik_load() { 86 | if true { 87 | let selector = #selector(setter: menuItems) 88 | let origIMP = class_getMethodImplementation(self, selector) 89 | typealias IMPType = @convention(c) (AnyObject, Selector, AnyObject?) -> Void 90 | let origIMPC = unsafeBitCast(origIMP, to: IMPType.self) 91 | let block: @convention(block) (AnyObject, AnyObject?) -> Void = { 92 | if let firstResp = UIResponder.mik_firstResponder { 93 | swizzle(type(of: firstResp.mik_responderToSwizzle)) 94 | } 95 | 96 | origIMPC($0, selector, $1.flatMap(makeUniqueImageTitles)) 97 | } 98 | 99 | setNewIMPWithBlock(block, forSelector: selector, toClass: self) 100 | } 101 | 102 | if true { 103 | let selector = #selector(setTargetRect(_:in:)) 104 | let origIMP = class_getMethodImplementation(self, selector) 105 | typealias IMPType = @convention(c) (AnyObject, Selector, CGRect, UIView) -> Void 106 | let origIMPC = unsafeBitCast(origIMP, to: IMPType.self) 107 | let block: @convention(block) (AnyObject, CGRect, UIView) -> Void = { 108 | swizzleUIObject($2); 109 | origIMPC($0, selector, $1, $2) 110 | } 111 | 112 | setNewIMPWithBlock(block, forSelector: selector, toClass: self) 113 | } 114 | 115 | if #available(iOS 13.0, *) { 116 | let selector = #selector(showMenu(from:rect:)) 117 | let origIMP = class_getMethodImplementation(self, selector) 118 | typealias IMPType = @convention(c) (AnyObject, Selector, UIView, CGRect) -> Void 119 | let origIMPC = unsafeBitCast(origIMP, to: IMPType.self) 120 | let block: @convention(block) (AnyObject, UIView, CGRect) -> Void = { 121 | swizzleUIObject($1); 122 | origIMPC($0, selector, $1, $2) 123 | } 124 | 125 | setNewIMPWithBlock(block, forSelector: selector, toClass: self) 126 | } 127 | } 128 | 129 | static func makeUniqueImageTitles(_ itemsObj: AnyObject) -> AnyObject { 130 | guard let items = itemsObj as? [UIMenuItem] else { return itemsObj } 131 | var dic = [String: [UIMenuItem]]() 132 | items.filter { $0.title.hasSuffix(imageItemIdetifier) }.forEach { item in 133 | if dic[item.title] == nil { dic[item.title] = [] } 134 | dic[item.title]?.append(item) 135 | } 136 | 137 | dic.filter { $1.count > 1 }.flatMap { $1 }.enumerated().forEach { index, item in 138 | item.title = (0...index).map { _ in imageItemIdetifier }.joined(separator: "") 139 | } 140 | 141 | return items as AnyObject 142 | } 143 | 144 | func findImageItemByTitle(_ title: String?) -> UIMenuItem? { 145 | guard title?.hasSuffix(imageItemIdetifier) == true else { return nil } 146 | return menuItems?.first { $0.title == title } 147 | } 148 | 149 | func findMenuItemBySelector(_ selector: Selector?) -> UIMenuItem? { 150 | guard let selector = selector else { return nil } 151 | return menuItems?.first { sel_isEqual($0.action, selector) } 152 | } 153 | 154 | func findMenuItemBySelector(_ selector: String?) -> UIMenuItem? { 155 | guard let selStr = selector else { return nil } 156 | return findMenuItemBySelector(NSSelectorFromString(selStr)) 157 | } 158 | } 159 | 160 | private extension UILabel { 161 | @objc class func _mik_load() { 162 | if true { 163 | let selector = #selector(drawText(in:)) 164 | let origIMP = class_getMethodImplementation(self, selector) 165 | typealias IMPType = @convention(c) (UILabel, Selector, CGRect) -> Void 166 | let origIMPC = unsafeBitCast(origIMP, to: IMPType.self) 167 | let block: @convention(block) (UILabel, CGRect) -> Void = { label, rect in 168 | guard 169 | let item = UIMenuController.shared.findImageItemByTitle(label.text), 170 | let _ = item.imageBox.value 171 | else { return origIMPC(label, selector, rect) } 172 | } 173 | 174 | setNewIMPWithBlock(block, forSelector: selector, toClass: self) 175 | } 176 | 177 | if true { 178 | let selector = #selector(layoutSubviews) 179 | let origIMP = class_getMethodImplementation(self, selector) 180 | typealias IMPType = @convention(c) (UILabel, Selector) -> Void 181 | let origIMPC = unsafeBitCast(origIMP, to: IMPType.self) 182 | let block: @convention(block) (UILabel) -> Void = { label in 183 | guard 184 | let item = UIMenuController.shared.findImageItemByTitle(label.text), 185 | let image = item.imageBox.value 186 | else { return origIMPC(label, selector) } 187 | 188 | // Workaround for #9: https://github.com/cxa/MenuItemKit/issues/9 189 | let point = CGPoint( 190 | x: (label.bounds.width - image.size.width) / 2, 191 | y: (label.bounds.height - image.size.height) / 2) 192 | let imageView: Box = label.associatedBoxForKey(#function, initialValue: { [weak label] in 193 | let imgView = UIImageView(frame: .zero) 194 | label?.addSubview(imgView) 195 | return imgView 196 | }()) 197 | 198 | imageView.value.image = image 199 | imageView.value.frame = CGRect(origin: point, size: image.size) 200 | } 201 | 202 | setNewIMPWithBlock(block, forSelector: selector, toClass: self) 203 | } 204 | 205 | if true { 206 | let selector = #selector(setter: frame) 207 | let origIMP = class_getMethodImplementation(self, selector) 208 | typealias IMPType = @convention(c) (UILabel, Selector, CGRect) -> Void 209 | let origIMPC = unsafeBitCast(origIMP, to: IMPType.self) 210 | let block: @convention(block) (UILabel, CGRect) -> Void = { label, rect in 211 | let isImageItem = UIMenuController.shared.findImageItemByTitle(label.text)?.imageBox.value != nil 212 | let rect = isImageItem ? label.superview?.bounds ?? rect : rect 213 | origIMPC(label, selector, rect) 214 | } 215 | 216 | setNewIMPWithBlock(block, forSelector: selector, toClass: self) 217 | } 218 | } 219 | } 220 | 221 | private extension NSString { 222 | @objc class func _mik_load() { 223 | let selector = #selector(size) 224 | let origIMP = class_getMethodImplementation(self, selector) 225 | typealias IMPType = @convention(c) (NSString, Selector, AnyObject) -> CGSize 226 | let origIMPC = unsafeBitCast(origIMP, to: IMPType.self) 227 | let block: @convention(block) (NSString, AnyObject) -> CGSize = { str, attr in 228 | guard 229 | let item = UIMenuController.shared.findImageItemByTitle(str as String), 230 | let image = item.imageBox.value 231 | else { 232 | return origIMPC(str, selector, attr) 233 | } 234 | 235 | return image.size 236 | } 237 | 238 | setNewIMPWithBlock(block, forSelector: selector, toClass: self) 239 | } 240 | } 241 | 242 | // MARK: Helper to find first responder 243 | // Source: http://stackoverflow.com/a/14135456/395213 244 | private weak var _currentFirstResponder: UIResponder? = nil 245 | 246 | private extension UIResponder { 247 | static var mik_firstResponder: UIResponder? { 248 | _currentFirstResponder = nil 249 | UIApplication.shared.sendAction(#selector(mik_findFirstResponder(_:)), to: nil, from: nil, for: nil) 250 | return _currentFirstResponder 251 | } 252 | 253 | @objc func mik_findFirstResponder(_ sender: AnyObject) { 254 | _currentFirstResponder = self 255 | } 256 | 257 | var mik_viewControllerInChain: UIResponder? { 258 | var nextR = Optional(self) 259 | while nextR != nil && nextR?.isKind(of: UIViewController.self) != true { 260 | nextR = nextR?.next 261 | } 262 | 263 | return nextR?.isKind(of: UIViewController.self) == true ? nextR : nil 264 | } 265 | 266 | var mik_responderToSwizzle: UIResponder { 267 | if let vc = mik_viewControllerInChain { return vc } 268 | return self 269 | } 270 | } 271 | 272 | private func swizzleUIObject(_ uiobj: UIView) { 273 | if let firstResp = UIResponder.mik_firstResponder { 274 | swizzle(type(of: firstResp.mik_responderToSwizzle)) 275 | } else { 276 | // Must call `becomeFirstResponder` since there's no firstResponder yet 277 | if let n = uiobj.mik_viewControllerInChain { 278 | swizzle(type(of: n)) 279 | n.becomeFirstResponder() 280 | } else { 281 | swizzle(type(of: uiobj)) 282 | uiobj.becomeFirstResponder() 283 | } 284 | } 285 | } 286 | -------------------------------------------------------------------------------- /MenuItemKit/Swift/UIMenuController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // UIMenuController.swift 3 | // MenuItemKit 4 | // 5 | // Created by CHEN Xian-an on 25/02/2018. 6 | // Copyright © 2018 lazyapps. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | public typealias ActionFilter = (_ action: Selector, _ default: Bool) -> Bool 12 | 13 | public extension UIMenuController { 14 | @objc(mik_installToResponder:shouldShowForAction:) 15 | static func installTo(responder: UIResponder, shouldShowForAction: @escaping ActionFilter = { $1 }) { 16 | swizzle(responder, shouldShowForAction: shouldShowForAction) 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /MenuItemKit/Swift/UIMenuItem.swift: -------------------------------------------------------------------------------- 1 | // 2 | // UIMenuItem.swift 3 | // MenuItemKit 4 | // 5 | // Created by CHEN Xian’an on 1/16/16. 6 | // Copyright © 2016 lazyapps. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | import ObjectiveC.runtime 11 | #if !NON_SPM 12 | @_exported import ObjCSwizzlings 13 | #endif 14 | 15 | public extension UIMenuItem { 16 | @objc(mik_initWithTitle:image:action:) 17 | convenience init(title: String, image: UIImage?, action: @escaping MenuItemAction) { 18 | let title = image != nil ? title + imageItemIdetifier : title 19 | self.init(title: title, action: Selector(blockIdentifierPrefix + UUID.stripedString + ":")) 20 | imageBox.value = image 21 | actionBox.value = action 22 | } 23 | 24 | @objc(mik_initWithTitle:action:) 25 | convenience init(title: String, action: @escaping MenuItemAction) { 26 | self.init(title: title, image: nil, action: action) 27 | } 28 | 29 | @objc(mik_isMenuItemKitSelector:) 30 | static func isMenuItemKitSelector(_ sel: Selector) -> Bool { 31 | return NSStringFromSelector(sel).hasPrefix(blockIdentifierPrefix) 32 | } 33 | } 34 | 35 | // MARK: NSUUID 36 | private extension UUID { 37 | static var stripedString: String { 38 | return UUID().uuidString.replacingOccurrences(of: "-", with: "_") 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /Package.swift: -------------------------------------------------------------------------------- 1 | // swift-tools-version:5.1 2 | // The swift-tools-version declares the minimum version of Swift required to build this package. 3 | 4 | import PackageDescription 5 | 6 | let package = Package( 7 | name: "MenuItemKit", 8 | products: [ 9 | .library(name: "MenuItemKit", targets: ["MenuItemKit"]) 10 | ], 11 | targets: [ 12 | .target(name: "ObjCSwizzlings", path: "./MenuItemKit/ObjCSwizzlings"), 13 | .target(name: "MenuItemKit", dependencies: ["ObjCSwizzlings"], path: "./MenuItemKit/Swift") 14 | ] 15 | ) 16 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | > **Warning** 2 | > `UIMenuController` is deprecated from iOS 16. Use `UIEditMenuInteraction` instead. 3 | 4 | # MenuItemKit 5 | 6 | `MenuItemKit` provides image and block(closure) support for `UIMenuItem`. 7 | 8 | `MenuItemKit` is a Swift project but Objective-C is supported without any doubt. 9 | 10 | ![Screenshot](Screenshot.png) 11 | 12 | ## Install 13 | 14 | ### Swift Package 15 | 16 | Add this repo URL to your Swift package dependencies. 17 | 18 | ### CocoaPods 19 | 20 | ```ruby 21 | pod 'MenuItemKit', '~> 4.0.0' 22 | ``` 23 | 24 | ### Xcode subproject 25 | 1. Add the `MenuItemKit` repository as a submodule of your application’s repository. 26 | 2. Drag and drop `MenuItemKit.xcodeproj` into your application’s Xcode project or workspace. 27 | 3. On the “General” tab of your application target’s settings, add `MenuItemKit.framework` to the “Embedded Binaries” section. 28 | 29 | If you would prefer to use Carthage, please pull request. 30 | 31 | ## How to use 32 | 33 | `MenuItemKit` is very easy to adopt, it provides only 2 APIs: 34 | 35 | ``` swift 36 | typealias MenuItemAction = (UIMenuItem) -> () 37 | 38 | extension UIMenuItem { 39 | convenience init(title: String, image: UIImage?, action: MenuItemAction) 40 | convenience init(title: String, action: MenuItemAction) 41 | } 42 | ``` 43 | 44 | For Objective-C, `MenuItemKit` provides prefixed API names for safe reasons: 45 | 46 | ```objc 47 | @interface UIMenuItem (SWIFT_EXTENSION(MenuItemKit)) 48 | - (nonnull instancetype)mik_initWithTitle:(NSString * _Nonnull)title image:(UIImage * _Nullable)image action:(MenuItemAction _Nonnull)action; 49 | - (nonnull instancetype)mik_initWithTitle:(NSString * _Nonnull)title action:(MenuItemAction _Nonnull)action; 50 | @end 51 | ``` 52 | 53 | Just init `UIMenuItem`s with above APIs, and set them to `menuItems` of `UIMenuItemController`. `MenuItemKit` will take care of the rest parts, you don't need to add any code related to responder chain in your view or view controller. 54 | 55 | Check dome projects (both Swift and Objective-C are provided) for more details. 56 | 57 | ## Advance Usage 58 | 59 | For menu items out of your control, you can use `static func installTo(responder: UIResponder, shouldShowForAction: @escaping (Selector, Bool) -> Bool = default)` to configure items visibility. Check [AutoPopupMenuControllerDemo](AutoPopupMenuControllerDemo). 60 | 61 | ## About Me 62 | 63 | * Twitter: [@_realazy](https://twitter.com/_realazy) 64 | * Apps available in App Store: 65 | * PayPal: xianan.chen+paypal 📧 gmail.com, buy me a cup of coffee if you find it's useful for you, thanks. 66 | 67 | ## License 68 | 69 | `MenuItemKit` is released under the MIT license. In short, it's royalty-free but you must keep the copyright notice in your code or software distribution. 70 | -------------------------------------------------------------------------------- /Screenshot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cxa/MenuItemKit/365321523300be357dd0665cfe048c4074203355/Screenshot.png --------------------------------------------------------------------------------