├── .gitignore ├── .swift-version ├── .swiftpm └── xcode │ └── package.xcworkspace │ └── contents.xcworkspacedata ├── ActionSheetController.podspec ├── ActionSheetController.xcodeproj ├── project.pbxproj ├── project.xcworkspace │ └── contents.xcworkspacedata └── xcshareddata │ └── xcschemes │ └── ActionSheetController.xcscheme ├── ActionSheetController.xcworkspace ├── contents.xcworkspacedata └── xcshareddata │ └── IDEWorkspaceChecks.plist ├── CHANGELOG.md ├── LICENSE ├── Package.resolved ├── Package.swift ├── Podfile ├── Podfile.lock ├── README.md ├── Sample ├── AppDelegate.swift ├── Assets.xcassets │ └── AppIcon.appiconset │ │ └── Contents.json ├── Base.lproj │ ├── LaunchScreen.storyboard │ └── Main.storyboard ├── Info.plist └── ViewController.swift ├── ScreenShoots ├── 1.gif └── 2.gif ├── Sources ├── ActionSheetController.h ├── ActionSheetController.swift ├── Info.plist └── SheetAction.swift └── Tests ├── ActionSheetControllerTests ├── ActionSheetControllerTests.swift └── XCTestManifests.swift └── LinuxMain.swift /.gitignore: -------------------------------------------------------------------------------- 1 | # Xcode 2 | # 3 | # gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore 4 | 5 | ## Build generated 6 | build/ 7 | DerivedData 8 | 9 | ## Various settings 10 | *.pbxuser 11 | !default.pbxuser 12 | *.mode1v3 13 | !default.mode1v3 14 | *.mode2v3 15 | !default.mode2v3 16 | *.perspectivev3 17 | !default.perspectivev3 18 | xcuserdata 19 | 20 | ## Other 21 | *.xccheckout 22 | *.moved-aside 23 | *.xcuserstate 24 | *.xcscmblueprint 25 | 26 | ## Obj-C/Swift specific 27 | *.hmap 28 | *.ipa 29 | 30 | ## Playgrounds 31 | timeline.xctimeline 32 | playground.xcworkspace 33 | 34 | # Swift Package Manager 35 | # 36 | # Add this line if you want to avoid checking in source code from Swift Package Manager dependencies. 37 | # Packages/ 38 | .build/ 39 | 40 | # CocoaPods 41 | # 42 | # We recommend against adding the Pods directory to your .gitignore. However 43 | # you should judge for yourself, the pros and cons are mentioned at: 44 | # https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control 45 | # 46 | Pods/ 47 | 48 | # Carthage 49 | # 50 | # Add this line if you want to avoid checking in source code from Carthage dependencies. 51 | # Carthage/Checkouts 52 | 53 | Carthage/Build 54 | 55 | # fastlane 56 | # 57 | # It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the 58 | # screenshots whenever they are needed. 59 | # For more information about the recommended setup visit: 60 | # https://github.com/fastlane/fastlane/blob/master/docs/Gitignore.md 61 | 62 | fastlane/report.xml 63 | fastlane/screenshots 64 | 65 | -------------------------------------------------------------------------------- /.swift-version: -------------------------------------------------------------------------------- 1 | 5.0 2 | -------------------------------------------------------------------------------- /.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /ActionSheetController.podspec: -------------------------------------------------------------------------------- 1 | Pod::Spec.new do |s| 2 | s.name = "ActionSheetController" 3 | s.version = "4.2.0" 4 | s.license = "MIT" 5 | s.summary = "ActionSheetController is an UIAlertController's APIs like ActionSheet control." 6 | s.homepage = "https://github.com/cuzv/ActionSheetController" 7 | s.author = { "Shaw" => "cuzval@gmail.com" } 8 | s.source = { :git => "https://github.com/cuzv/ActionSheetController.git", :tag => s.version } 9 | 10 | s.ios.deployment_target = "8.0" 11 | s.source_files = "Sources/*.swift" 12 | s.requires_arc = true 13 | s.dependency "ModalTransitioning", "~> 5.0" 14 | end 15 | -------------------------------------------------------------------------------- /ActionSheetController.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 46778E331C916FF0004AF36E /* ActionSheetController.h in Headers */ = {isa = PBXBuildFile; fileRef = 46778E321C916FF0004AF36E /* ActionSheetController.h */; settings = {ATTRIBUTES = (Public, ); }; }; 11 | 46778E461C91707E004AF36E /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 46778E451C91707E004AF36E /* AppDelegate.swift */; }; 12 | 46778E481C91707E004AF36E /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 46778E471C91707E004AF36E /* ViewController.swift */; }; 13 | 46778E4B1C91707E004AF36E /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 46778E491C91707E004AF36E /* Main.storyboard */; }; 14 | 46778E4D1C91707E004AF36E /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 46778E4C1C91707E004AF36E /* Assets.xcassets */; }; 15 | 46778E501C91707E004AF36E /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 46778E4E1C91707E004AF36E /* LaunchScreen.storyboard */; }; 16 | 467E0DD51CAA63D400257CF3 /* ActionSheetController.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 46778E2F1C916FF0004AF36E /* ActionSheetController.framework */; }; 17 | 467E0DD61CAA63D400257CF3 /* ActionSheetController.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 46778E2F1C916FF0004AF36E /* ActionSheetController.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; 18 | 46D9CEC91CC644B9005F0B9B /* ActionSheetController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 46D9CEC61CC644B9005F0B9B /* ActionSheetController.swift */; }; 19 | 46D9CECB1CC644B9005F0B9B /* SheetAction.swift in Sources */ = {isa = PBXBuildFile; fileRef = 46D9CEC81CC644B9005F0B9B /* SheetAction.swift */; }; 20 | 9A3EB501A4DAB81C668E6F0A /* Pods_Sample.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1C25399D515AE0287430CB3E /* Pods_Sample.framework */; }; 21 | F939578A20BEDDEF00FA900C /* Pods_ActionSheetController.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = F939578920BEDDEF00FA900C /* Pods_ActionSheetController.framework */; }; 22 | /* End PBXBuildFile section */ 23 | 24 | /* Begin PBXContainerItemProxy section */ 25 | 467E0DD71CAA63D400257CF3 /* PBXContainerItemProxy */ = { 26 | isa = PBXContainerItemProxy; 27 | containerPortal = 46778E261C916FF0004AF36E /* Project object */; 28 | proxyType = 1; 29 | remoteGlobalIDString = 46778E2E1C916FF0004AF36E; 30 | remoteInfo = ActionSheetController; 31 | }; 32 | /* End PBXContainerItemProxy section */ 33 | 34 | /* Begin PBXCopyFilesBuildPhase section */ 35 | 467E0DD91CAA63D400257CF3 /* Embed Frameworks */ = { 36 | isa = PBXCopyFilesBuildPhase; 37 | buildActionMask = 2147483647; 38 | dstPath = ""; 39 | dstSubfolderSpec = 10; 40 | files = ( 41 | 467E0DD61CAA63D400257CF3 /* ActionSheetController.framework in Embed Frameworks */, 42 | ); 43 | name = "Embed Frameworks"; 44 | runOnlyForDeploymentPostprocessing = 0; 45 | }; 46 | /* End PBXCopyFilesBuildPhase section */ 47 | 48 | /* Begin PBXFileReference section */ 49 | 1C25399D515AE0287430CB3E /* Pods_Sample.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_Sample.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 50 | 461549861DB7098200DA6DC4 /* Pods_ActionSheetController.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Pods_ActionSheetController.framework; path = "../../Library/Developer/Xcode/DerivedData/ActionSheetController-ddgaterhlqsyzodsjrbtyottlfhj/Build/Products/Debug-iphonesimulator/Pods_ActionSheetController.framework"; sourceTree = ""; }; 51 | 461549881DB709B800DA6DC4 /* PresentAnimatedTransitioningController.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = PresentAnimatedTransitioningController.framework; path = "../../Library/Developer/Xcode/DerivedData/ActionSheetController-ddgaterhlqsyzodsjrbtyottlfhj/Build/Products/Debug-iphonesimulator/PresentAnimatedTransitioningController/PresentAnimatedTransitioningController.framework"; sourceTree = ""; }; 52 | 46778E2F1C916FF0004AF36E /* ActionSheetController.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = ActionSheetController.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 53 | 46778E321C916FF0004AF36E /* ActionSheetController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ActionSheetController.h; sourceTree = ""; }; 54 | 46778E341C916FF0004AF36E /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 55 | 46778E431C91707E004AF36E /* Sample.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Sample.app; sourceTree = BUILT_PRODUCTS_DIR; }; 56 | 46778E451C91707E004AF36E /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 57 | 46778E471C91707E004AF36E /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = ""; }; 58 | 46778E4A1C91707E004AF36E /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 59 | 46778E4C1C91707E004AF36E /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 60 | 46778E4F1C91707E004AF36E /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 61 | 46778E511C91707E004AF36E /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 62 | 46D9CEC61CC644B9005F0B9B /* ActionSheetController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ActionSheetController.swift; sourceTree = ""; }; 63 | 46D9CEC81CC644B9005F0B9B /* SheetAction.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SheetAction.swift; sourceTree = ""; }; 64 | 87258EF33B0E273797AB562B /* Pods-ActionSheetController.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-ActionSheetController.debug.xcconfig"; path = "Pods/Target Support Files/Pods-ActionSheetController/Pods-ActionSheetController.debug.xcconfig"; sourceTree = ""; }; 65 | A544A797CE0F1A4AC12AC78B /* Pods-Sample.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Sample.release.xcconfig"; path = "Pods/Target Support Files/Pods-Sample/Pods-Sample.release.xcconfig"; sourceTree = ""; }; 66 | D68617EE77FFA831E6B30AF5 /* Pods-Sample.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Sample.debug.xcconfig"; path = "Pods/Target Support Files/Pods-Sample/Pods-Sample.debug.xcconfig"; sourceTree = ""; }; 67 | F70E7153FE19C343CB7CB8DD /* Pods-ActionSheetController.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-ActionSheetController.release.xcconfig"; path = "Pods/Target Support Files/Pods-ActionSheetController/Pods-ActionSheetController.release.xcconfig"; sourceTree = ""; }; 68 | F939578920BEDDEF00FA900C /* Pods_ActionSheetController.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; path = Pods_ActionSheetController.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 69 | /* End PBXFileReference section */ 70 | 71 | /* Begin PBXFrameworksBuildPhase section */ 72 | 46778E2B1C916FF0004AF36E /* Frameworks */ = { 73 | isa = PBXFrameworksBuildPhase; 74 | buildActionMask = 2147483647; 75 | files = ( 76 | F939578A20BEDDEF00FA900C /* Pods_ActionSheetController.framework in Frameworks */, 77 | ); 78 | runOnlyForDeploymentPostprocessing = 0; 79 | }; 80 | 46778E401C91707E004AF36E /* Frameworks */ = { 81 | isa = PBXFrameworksBuildPhase; 82 | buildActionMask = 2147483647; 83 | files = ( 84 | 467E0DD51CAA63D400257CF3 /* ActionSheetController.framework in Frameworks */, 85 | 9A3EB501A4DAB81C668E6F0A /* Pods_Sample.framework in Frameworks */, 86 | ); 87 | runOnlyForDeploymentPostprocessing = 0; 88 | }; 89 | /* End PBXFrameworksBuildPhase section */ 90 | 91 | /* Begin PBXGroup section */ 92 | 46778E251C916FF0004AF36E = { 93 | isa = PBXGroup; 94 | children = ( 95 | 46778E311C916FF0004AF36E /* Sources */, 96 | 46778E441C91707E004AF36E /* Sample */, 97 | 46778E301C916FF0004AF36E /* Products */, 98 | D4EE80C9D6DF88F34558A632 /* Frameworks */, 99 | C56756C1B5CFD725827A76FA /* Pods */, 100 | ); 101 | sourceTree = ""; 102 | }; 103 | 46778E301C916FF0004AF36E /* Products */ = { 104 | isa = PBXGroup; 105 | children = ( 106 | 46778E2F1C916FF0004AF36E /* ActionSheetController.framework */, 107 | 46778E431C91707E004AF36E /* Sample.app */, 108 | ); 109 | name = Products; 110 | sourceTree = ""; 111 | }; 112 | 46778E311C916FF0004AF36E /* Sources */ = { 113 | isa = PBXGroup; 114 | children = ( 115 | 46D9CEC61CC644B9005F0B9B /* ActionSheetController.swift */, 116 | 46D9CEC81CC644B9005F0B9B /* SheetAction.swift */, 117 | 46778E321C916FF0004AF36E /* ActionSheetController.h */, 118 | 46778E341C916FF0004AF36E /* Info.plist */, 119 | ); 120 | path = Sources; 121 | sourceTree = ""; 122 | }; 123 | 46778E441C91707E004AF36E /* Sample */ = { 124 | isa = PBXGroup; 125 | children = ( 126 | 46778E451C91707E004AF36E /* AppDelegate.swift */, 127 | 46778E471C91707E004AF36E /* ViewController.swift */, 128 | 46778E491C91707E004AF36E /* Main.storyboard */, 129 | 46778E4C1C91707E004AF36E /* Assets.xcassets */, 130 | 46778E4E1C91707E004AF36E /* LaunchScreen.storyboard */, 131 | 46778E511C91707E004AF36E /* Info.plist */, 132 | ); 133 | path = Sample; 134 | sourceTree = ""; 135 | }; 136 | C56756C1B5CFD725827A76FA /* Pods */ = { 137 | isa = PBXGroup; 138 | children = ( 139 | 87258EF33B0E273797AB562B /* Pods-ActionSheetController.debug.xcconfig */, 140 | F70E7153FE19C343CB7CB8DD /* Pods-ActionSheetController.release.xcconfig */, 141 | D68617EE77FFA831E6B30AF5 /* Pods-Sample.debug.xcconfig */, 142 | A544A797CE0F1A4AC12AC78B /* Pods-Sample.release.xcconfig */, 143 | ); 144 | name = Pods; 145 | sourceTree = ""; 146 | }; 147 | D4EE80C9D6DF88F34558A632 /* Frameworks */ = { 148 | isa = PBXGroup; 149 | children = ( 150 | F939578920BEDDEF00FA900C /* Pods_ActionSheetController.framework */, 151 | 461549881DB709B800DA6DC4 /* PresentAnimatedTransitioningController.framework */, 152 | 461549861DB7098200DA6DC4 /* Pods_ActionSheetController.framework */, 153 | 1C25399D515AE0287430CB3E /* Pods_Sample.framework */, 154 | ); 155 | name = Frameworks; 156 | sourceTree = ""; 157 | }; 158 | /* End PBXGroup section */ 159 | 160 | /* Begin PBXHeadersBuildPhase section */ 161 | 46778E2C1C916FF0004AF36E /* Headers */ = { 162 | isa = PBXHeadersBuildPhase; 163 | buildActionMask = 2147483647; 164 | files = ( 165 | 46778E331C916FF0004AF36E /* ActionSheetController.h in Headers */, 166 | ); 167 | runOnlyForDeploymentPostprocessing = 0; 168 | }; 169 | /* End PBXHeadersBuildPhase section */ 170 | 171 | /* Begin PBXNativeTarget section */ 172 | 46778E2E1C916FF0004AF36E /* ActionSheetController */ = { 173 | isa = PBXNativeTarget; 174 | buildConfigurationList = 46778E371C916FF0004AF36E /* Build configuration list for PBXNativeTarget "ActionSheetController" */; 175 | buildPhases = ( 176 | 2343C94A9EABE3BC6981EA96 /* [CP] Check Pods Manifest.lock */, 177 | 46778E2A1C916FF0004AF36E /* Sources */, 178 | 46778E2B1C916FF0004AF36E /* Frameworks */, 179 | 46778E2C1C916FF0004AF36E /* Headers */, 180 | 46778E2D1C916FF0004AF36E /* Resources */, 181 | ); 182 | buildRules = ( 183 | ); 184 | dependencies = ( 185 | ); 186 | name = ActionSheetController; 187 | productName = ActionSheetController; 188 | productReference = 46778E2F1C916FF0004AF36E /* ActionSheetController.framework */; 189 | productType = "com.apple.product-type.framework"; 190 | }; 191 | 46778E421C91707E004AF36E /* Sample */ = { 192 | isa = PBXNativeTarget; 193 | buildConfigurationList = 46778E521C91707E004AF36E /* Build configuration list for PBXNativeTarget "Sample" */; 194 | buildPhases = ( 195 | 23477AC4B4A3A62C22A285FB /* [CP] Check Pods Manifest.lock */, 196 | 46778E3F1C91707E004AF36E /* Sources */, 197 | 46778E401C91707E004AF36E /* Frameworks */, 198 | 46778E411C91707E004AF36E /* Resources */, 199 | 467E0DD91CAA63D400257CF3 /* Embed Frameworks */, 200 | 2ED9CE22898011D889B179CD /* [CP] Embed Pods Frameworks */, 201 | ); 202 | buildRules = ( 203 | ); 204 | dependencies = ( 205 | 467E0DD81CAA63D400257CF3 /* PBXTargetDependency */, 206 | ); 207 | name = Sample; 208 | productName = Sample; 209 | productReference = 46778E431C91707E004AF36E /* Sample.app */; 210 | productType = "com.apple.product-type.application"; 211 | }; 212 | /* End PBXNativeTarget section */ 213 | 214 | /* Begin PBXProject section */ 215 | 46778E261C916FF0004AF36E /* Project object */ = { 216 | isa = PBXProject; 217 | attributes = { 218 | LastSwiftUpdateCheck = 0730; 219 | LastUpgradeCheck = 1020; 220 | ORGANIZATIONNAME = Moch; 221 | TargetAttributes = { 222 | 46778E2E1C916FF0004AF36E = { 223 | CreatedOnToolsVersion = 7.2.1; 224 | DevelopmentTeam = XDN35K5RF2; 225 | LastSwiftMigration = 1020; 226 | }; 227 | 46778E421C91707E004AF36E = { 228 | CreatedOnToolsVersion = 7.2.1; 229 | DevelopmentTeam = XDN35K5RF2; 230 | LastSwiftMigration = 1020; 231 | }; 232 | }; 233 | }; 234 | buildConfigurationList = 46778E291C916FF0004AF36E /* Build configuration list for PBXProject "ActionSheetController" */; 235 | compatibilityVersion = "Xcode 3.2"; 236 | developmentRegion = English; 237 | hasScannedForEncodings = 0; 238 | knownRegions = ( 239 | English, 240 | en, 241 | Base, 242 | ); 243 | mainGroup = 46778E251C916FF0004AF36E; 244 | productRefGroup = 46778E301C916FF0004AF36E /* Products */; 245 | projectDirPath = ""; 246 | projectRoot = ""; 247 | targets = ( 248 | 46778E2E1C916FF0004AF36E /* ActionSheetController */, 249 | 46778E421C91707E004AF36E /* Sample */, 250 | ); 251 | }; 252 | /* End PBXProject section */ 253 | 254 | /* Begin PBXResourcesBuildPhase section */ 255 | 46778E2D1C916FF0004AF36E /* Resources */ = { 256 | isa = PBXResourcesBuildPhase; 257 | buildActionMask = 2147483647; 258 | files = ( 259 | ); 260 | runOnlyForDeploymentPostprocessing = 0; 261 | }; 262 | 46778E411C91707E004AF36E /* Resources */ = { 263 | isa = PBXResourcesBuildPhase; 264 | buildActionMask = 2147483647; 265 | files = ( 266 | 46778E501C91707E004AF36E /* LaunchScreen.storyboard in Resources */, 267 | 46778E4D1C91707E004AF36E /* Assets.xcassets in Resources */, 268 | 46778E4B1C91707E004AF36E /* Main.storyboard in Resources */, 269 | ); 270 | runOnlyForDeploymentPostprocessing = 0; 271 | }; 272 | /* End PBXResourcesBuildPhase section */ 273 | 274 | /* Begin PBXShellScriptBuildPhase section */ 275 | 2343C94A9EABE3BC6981EA96 /* [CP] Check Pods Manifest.lock */ = { 276 | isa = PBXShellScriptBuildPhase; 277 | buildActionMask = 2147483647; 278 | files = ( 279 | ); 280 | inputPaths = ( 281 | "${PODS_PODFILE_DIR_PATH}/Podfile.lock", 282 | "${PODS_ROOT}/Manifest.lock", 283 | ); 284 | name = "[CP] Check Pods Manifest.lock"; 285 | outputPaths = ( 286 | "$(DERIVED_FILE_DIR)/Pods-ActionSheetController-checkManifestLockResult.txt", 287 | ); 288 | runOnlyForDeploymentPostprocessing = 0; 289 | shellPath = /bin/sh; 290 | shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; 291 | showEnvVarsInLog = 0; 292 | }; 293 | 23477AC4B4A3A62C22A285FB /* [CP] Check Pods Manifest.lock */ = { 294 | isa = PBXShellScriptBuildPhase; 295 | buildActionMask = 2147483647; 296 | files = ( 297 | ); 298 | inputPaths = ( 299 | "${PODS_PODFILE_DIR_PATH}/Podfile.lock", 300 | "${PODS_ROOT}/Manifest.lock", 301 | ); 302 | name = "[CP] Check Pods Manifest.lock"; 303 | outputPaths = ( 304 | "$(DERIVED_FILE_DIR)/Pods-Sample-checkManifestLockResult.txt", 305 | ); 306 | runOnlyForDeploymentPostprocessing = 0; 307 | shellPath = /bin/sh; 308 | shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; 309 | showEnvVarsInLog = 0; 310 | }; 311 | 2ED9CE22898011D889B179CD /* [CP] Embed Pods Frameworks */ = { 312 | isa = PBXShellScriptBuildPhase; 313 | buildActionMask = 2147483647; 314 | files = ( 315 | ); 316 | inputPaths = ( 317 | "${PODS_ROOT}/Target Support Files/Pods-Sample/Pods-Sample-frameworks.sh", 318 | "${BUILT_PRODUCTS_DIR}/ModalTransitioning/ModalTransitioning.framework", 319 | ); 320 | name = "[CP] Embed Pods Frameworks"; 321 | outputPaths = ( 322 | "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/ModalTransitioning.framework", 323 | ); 324 | runOnlyForDeploymentPostprocessing = 0; 325 | shellPath = /bin/sh; 326 | shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-Sample/Pods-Sample-frameworks.sh\"\n"; 327 | showEnvVarsInLog = 0; 328 | }; 329 | /* End PBXShellScriptBuildPhase section */ 330 | 331 | /* Begin PBXSourcesBuildPhase section */ 332 | 46778E2A1C916FF0004AF36E /* Sources */ = { 333 | isa = PBXSourcesBuildPhase; 334 | buildActionMask = 2147483647; 335 | files = ( 336 | 46D9CECB1CC644B9005F0B9B /* SheetAction.swift in Sources */, 337 | 46D9CEC91CC644B9005F0B9B /* ActionSheetController.swift in Sources */, 338 | ); 339 | runOnlyForDeploymentPostprocessing = 0; 340 | }; 341 | 46778E3F1C91707E004AF36E /* Sources */ = { 342 | isa = PBXSourcesBuildPhase; 343 | buildActionMask = 2147483647; 344 | files = ( 345 | 46778E481C91707E004AF36E /* ViewController.swift in Sources */, 346 | 46778E461C91707E004AF36E /* AppDelegate.swift in Sources */, 347 | ); 348 | runOnlyForDeploymentPostprocessing = 0; 349 | }; 350 | /* End PBXSourcesBuildPhase section */ 351 | 352 | /* Begin PBXTargetDependency section */ 353 | 467E0DD81CAA63D400257CF3 /* PBXTargetDependency */ = { 354 | isa = PBXTargetDependency; 355 | target = 46778E2E1C916FF0004AF36E /* ActionSheetController */; 356 | targetProxy = 467E0DD71CAA63D400257CF3 /* PBXContainerItemProxy */; 357 | }; 358 | /* End PBXTargetDependency section */ 359 | 360 | /* Begin PBXVariantGroup section */ 361 | 46778E491C91707E004AF36E /* Main.storyboard */ = { 362 | isa = PBXVariantGroup; 363 | children = ( 364 | 46778E4A1C91707E004AF36E /* Base */, 365 | ); 366 | name = Main.storyboard; 367 | sourceTree = ""; 368 | }; 369 | 46778E4E1C91707E004AF36E /* LaunchScreen.storyboard */ = { 370 | isa = PBXVariantGroup; 371 | children = ( 372 | 46778E4F1C91707E004AF36E /* Base */, 373 | ); 374 | name = LaunchScreen.storyboard; 375 | sourceTree = ""; 376 | }; 377 | /* End PBXVariantGroup section */ 378 | 379 | /* Begin XCBuildConfiguration section */ 380 | 46778E351C916FF0004AF36E /* Debug */ = { 381 | isa = XCBuildConfiguration; 382 | buildSettings = { 383 | ALWAYS_SEARCH_USER_PATHS = NO; 384 | CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES; 385 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 386 | CLANG_CXX_LIBRARY = "libc++"; 387 | CLANG_ENABLE_MODULES = YES; 388 | CLANG_ENABLE_OBJC_ARC = YES; 389 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 390 | CLANG_WARN_BOOL_CONVERSION = YES; 391 | CLANG_WARN_COMMA = YES; 392 | CLANG_WARN_CONSTANT_CONVERSION = YES; 393 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 394 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 395 | CLANG_WARN_EMPTY_BODY = YES; 396 | CLANG_WARN_ENUM_CONVERSION = YES; 397 | CLANG_WARN_INFINITE_RECURSION = YES; 398 | CLANG_WARN_INT_CONVERSION = YES; 399 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 400 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 401 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 402 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 403 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 404 | CLANG_WARN_STRICT_PROTOTYPES = YES; 405 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 406 | CLANG_WARN_UNREACHABLE_CODE = YES; 407 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 408 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 409 | COPY_PHASE_STRIP = NO; 410 | CURRENT_PROJECT_VERSION = 1; 411 | DEBUG_INFORMATION_FORMAT = dwarf; 412 | ENABLE_STRICT_OBJC_MSGSEND = YES; 413 | ENABLE_TESTABILITY = YES; 414 | GCC_C_LANGUAGE_STANDARD = gnu99; 415 | GCC_DYNAMIC_NO_PIC = NO; 416 | GCC_NO_COMMON_BLOCKS = YES; 417 | GCC_OPTIMIZATION_LEVEL = 0; 418 | GCC_PREPROCESSOR_DEFINITIONS = ( 419 | "DEBUG=1", 420 | "$(inherited)", 421 | ); 422 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 423 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 424 | GCC_WARN_UNDECLARED_SELECTOR = YES; 425 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 426 | GCC_WARN_UNUSED_FUNCTION = YES; 427 | GCC_WARN_UNUSED_VARIABLE = YES; 428 | IPHONEOS_DEPLOYMENT_TARGET = 8.0; 429 | MTL_ENABLE_DEBUG_INFO = YES; 430 | ONLY_ACTIVE_ARCH = YES; 431 | SDKROOT = iphoneos; 432 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 433 | SWIFT_VERSION = 5.0; 434 | TARGETED_DEVICE_FAMILY = "1,2"; 435 | VERSIONING_SYSTEM = "apple-generic"; 436 | VERSION_INFO_PREFIX = ""; 437 | }; 438 | name = Debug; 439 | }; 440 | 46778E361C916FF0004AF36E /* Release */ = { 441 | isa = XCBuildConfiguration; 442 | buildSettings = { 443 | ALWAYS_SEARCH_USER_PATHS = NO; 444 | CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES; 445 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 446 | CLANG_CXX_LIBRARY = "libc++"; 447 | CLANG_ENABLE_MODULES = YES; 448 | CLANG_ENABLE_OBJC_ARC = YES; 449 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 450 | CLANG_WARN_BOOL_CONVERSION = YES; 451 | CLANG_WARN_COMMA = YES; 452 | CLANG_WARN_CONSTANT_CONVERSION = YES; 453 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 454 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 455 | CLANG_WARN_EMPTY_BODY = YES; 456 | CLANG_WARN_ENUM_CONVERSION = YES; 457 | CLANG_WARN_INFINITE_RECURSION = YES; 458 | CLANG_WARN_INT_CONVERSION = YES; 459 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 460 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 461 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 462 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 463 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 464 | CLANG_WARN_STRICT_PROTOTYPES = YES; 465 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 466 | CLANG_WARN_UNREACHABLE_CODE = YES; 467 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 468 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 469 | COPY_PHASE_STRIP = NO; 470 | CURRENT_PROJECT_VERSION = 1; 471 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 472 | ENABLE_NS_ASSERTIONS = NO; 473 | ENABLE_STRICT_OBJC_MSGSEND = YES; 474 | GCC_C_LANGUAGE_STANDARD = gnu99; 475 | GCC_NO_COMMON_BLOCKS = YES; 476 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 477 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 478 | GCC_WARN_UNDECLARED_SELECTOR = YES; 479 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 480 | GCC_WARN_UNUSED_FUNCTION = YES; 481 | GCC_WARN_UNUSED_VARIABLE = YES; 482 | IPHONEOS_DEPLOYMENT_TARGET = 8.0; 483 | MTL_ENABLE_DEBUG_INFO = NO; 484 | SDKROOT = iphoneos; 485 | SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; 486 | SWIFT_VERSION = 5.0; 487 | TARGETED_DEVICE_FAMILY = "1,2"; 488 | VALIDATE_PRODUCT = YES; 489 | VERSIONING_SYSTEM = "apple-generic"; 490 | VERSION_INFO_PREFIX = ""; 491 | }; 492 | name = Release; 493 | }; 494 | 46778E381C916FF0004AF36E /* Debug */ = { 495 | isa = XCBuildConfiguration; 496 | baseConfigurationReference = 87258EF33B0E273797AB562B /* Pods-ActionSheetController.debug.xcconfig */; 497 | buildSettings = { 498 | CLANG_ENABLE_MODULES = YES; 499 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = ""; 500 | DEFINES_MODULE = YES; 501 | DEVELOPMENT_TEAM = XDN35K5RF2; 502 | DYLIB_COMPATIBILITY_VERSION = 1; 503 | DYLIB_CURRENT_VERSION = 1; 504 | DYLIB_INSTALL_NAME_BASE = "@rpath"; 505 | INFOPLIST_FILE = "$(SRCROOT)/Sources/Info.plist"; 506 | INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; 507 | IPHONEOS_DEPLOYMENT_TARGET = 8.0; 508 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 509 | PRODUCT_BUNDLE_IDENTIFIER = com.mochxiao.ActionSheetController; 510 | PRODUCT_NAME = "$(TARGET_NAME)"; 511 | SKIP_INSTALL = YES; 512 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 513 | SWIFT_VERSION = 5.0; 514 | }; 515 | name = Debug; 516 | }; 517 | 46778E391C916FF0004AF36E /* Release */ = { 518 | isa = XCBuildConfiguration; 519 | baseConfigurationReference = F70E7153FE19C343CB7CB8DD /* Pods-ActionSheetController.release.xcconfig */; 520 | buildSettings = { 521 | CLANG_ENABLE_MODULES = YES; 522 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = ""; 523 | DEFINES_MODULE = YES; 524 | DEVELOPMENT_TEAM = XDN35K5RF2; 525 | DYLIB_COMPATIBILITY_VERSION = 1; 526 | DYLIB_CURRENT_VERSION = 1; 527 | DYLIB_INSTALL_NAME_BASE = "@rpath"; 528 | INFOPLIST_FILE = "$(SRCROOT)/Sources/Info.plist"; 529 | INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; 530 | IPHONEOS_DEPLOYMENT_TARGET = 8.0; 531 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 532 | PRODUCT_BUNDLE_IDENTIFIER = com.mochxiao.ActionSheetController; 533 | PRODUCT_NAME = "$(TARGET_NAME)"; 534 | SKIP_INSTALL = YES; 535 | SWIFT_VERSION = 5.0; 536 | }; 537 | name = Release; 538 | }; 539 | 46778E531C91707E004AF36E /* Debug */ = { 540 | isa = XCBuildConfiguration; 541 | baseConfigurationReference = D68617EE77FFA831E6B30AF5 /* Pods-Sample.debug.xcconfig */; 542 | buildSettings = { 543 | ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; 544 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 545 | DEVELOPMENT_TEAM = XDN35K5RF2; 546 | INFOPLIST_FILE = Sample/Info.plist; 547 | IPHONEOS_DEPLOYMENT_TARGET = 8.0; 548 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 549 | PRODUCT_BUNDLE_IDENTIFIER = com.mochxiao.Sample; 550 | PRODUCT_NAME = "$(TARGET_NAME)"; 551 | SWIFT_VERSION = 5.0; 552 | }; 553 | name = Debug; 554 | }; 555 | 46778E541C91707E004AF36E /* Release */ = { 556 | isa = XCBuildConfiguration; 557 | baseConfigurationReference = A544A797CE0F1A4AC12AC78B /* Pods-Sample.release.xcconfig */; 558 | buildSettings = { 559 | ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; 560 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 561 | DEVELOPMENT_TEAM = XDN35K5RF2; 562 | INFOPLIST_FILE = Sample/Info.plist; 563 | IPHONEOS_DEPLOYMENT_TARGET = 8.0; 564 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 565 | PRODUCT_BUNDLE_IDENTIFIER = com.mochxiao.Sample; 566 | PRODUCT_NAME = "$(TARGET_NAME)"; 567 | SWIFT_VERSION = 5.0; 568 | }; 569 | name = Release; 570 | }; 571 | /* End XCBuildConfiguration section */ 572 | 573 | /* Begin XCConfigurationList section */ 574 | 46778E291C916FF0004AF36E /* Build configuration list for PBXProject "ActionSheetController" */ = { 575 | isa = XCConfigurationList; 576 | buildConfigurations = ( 577 | 46778E351C916FF0004AF36E /* Debug */, 578 | 46778E361C916FF0004AF36E /* Release */, 579 | ); 580 | defaultConfigurationIsVisible = 0; 581 | defaultConfigurationName = Release; 582 | }; 583 | 46778E371C916FF0004AF36E /* Build configuration list for PBXNativeTarget "ActionSheetController" */ = { 584 | isa = XCConfigurationList; 585 | buildConfigurations = ( 586 | 46778E381C916FF0004AF36E /* Debug */, 587 | 46778E391C916FF0004AF36E /* Release */, 588 | ); 589 | defaultConfigurationIsVisible = 0; 590 | defaultConfigurationName = Release; 591 | }; 592 | 46778E521C91707E004AF36E /* Build configuration list for PBXNativeTarget "Sample" */ = { 593 | isa = XCConfigurationList; 594 | buildConfigurations = ( 595 | 46778E531C91707E004AF36E /* Debug */, 596 | 46778E541C91707E004AF36E /* Release */, 597 | ); 598 | defaultConfigurationIsVisible = 0; 599 | defaultConfigurationName = Release; 600 | }; 601 | /* End XCConfigurationList section */ 602 | }; 603 | rootObject = 46778E261C916FF0004AF36E /* Project object */; 604 | } 605 | -------------------------------------------------------------------------------- /ActionSheetController.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /ActionSheetController.xcodeproj/xcshareddata/xcschemes/ActionSheetController.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 32 | 33 | 34 | 35 | 45 | 46 | 52 | 53 | 54 | 55 | 56 | 57 | 63 | 64 | 70 | 71 | 72 | 73 | 75 | 76 | 79 | 80 | 81 | -------------------------------------------------------------------------------- /ActionSheetController.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /ActionSheetController.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | ### 0.1.1 2 | 3 | - 点击按钮后自动退出 4 | 5 | ### 0.1.2 6 | 7 | - 按钮行高修改为50pt 8 | 9 | ### 0.1.3 10 | 11 | - 支持Xcode 7.3 & Swift 2.2 12 | 13 | ### 0.2.0 14 | 15 | - 添加半透明效果 16 | 17 | ### 0.2.1 18 | 19 | - 修改透明度 20 | 21 | ### 2.1.1 22 | 23 | - 添加title 24 | 25 | 26 | ### 2.1.2 27 | 28 | - touchs end dismiss -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2016 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /Package.resolved: -------------------------------------------------------------------------------- 1 | { 2 | "object": { 3 | "pins": [ 4 | { 5 | "package": "ModalTransitioning", 6 | "repositoryURL": "https://github.com/cuzv/ModalTransitioning", 7 | "state": { 8 | "branch": "master", 9 | "revision": "0f0e3ba9cf86e31e22f86dbc23d900b2516604bf", 10 | "version": null 11 | } 12 | } 13 | ] 14 | }, 15 | "version": 1 16 | } 17 | -------------------------------------------------------------------------------- /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: "ActionSheetController", 8 | platforms: [ 9 | .iOS(.v8) 10 | ], 11 | products: [ 12 | // Products define the executables and libraries produced by a package, and make them visible to other packages. 13 | .library( 14 | name: "ActionSheetController", 15 | targets: ["ActionSheetController"] 16 | ), 17 | ], 18 | dependencies: [ 19 | // Dependencies declare other packages that this package depends on. 20 | // .package(url: /* package url */, from: "1.0.0"), 21 | .package(url: "https://github.com/cuzv/ModalTransitioning", .branch("master")), 22 | ], 23 | targets: [ 24 | // Targets are the basic building blocks of a package. A target can define a module or a test suite. 25 | // Targets can depend on other targets in this package, and on products in packages which this package depends on. 26 | .target( 27 | name: "ActionSheetController", 28 | dependencies: ["ModalTransitioning"], 29 | path: "Sources" 30 | ), 31 | .testTarget( 32 | name: "ActionSheetControllerTests", 33 | dependencies: ["ActionSheetController"] 34 | ), 35 | ] 36 | ) 37 | -------------------------------------------------------------------------------- /Podfile: -------------------------------------------------------------------------------- 1 | platform :ios, '8.0' 2 | source 'https://github.com/CocoaPods/Specs.git' 3 | use_frameworks! 4 | 5 | def dependency 6 | pod 'ModalTransitioning', '~> 4.0' 7 | end 8 | 9 | target 'ActionSheetController' do 10 | dependency 11 | end 12 | 13 | target 'Sample' do 14 | dependency 15 | end 16 | 17 | -------------------------------------------------------------------------------- /Podfile.lock: -------------------------------------------------------------------------------- 1 | PODS: 2 | - ModalTransitioning (4.4.0) 3 | 4 | DEPENDENCIES: 5 | - ModalTransitioning (~> 4.0) 6 | 7 | SPEC REPOS: 8 | https://github.com/cocoapods/specs.git: 9 | - ModalTransitioning 10 | 11 | SPEC CHECKSUMS: 12 | ModalTransitioning: 60ac40baa00bdb335d34bbaa51598c70ea1eb9a3 13 | 14 | PODFILE CHECKSUM: f01c06517cdf9cf34a7d68601ed268de470b5335 15 | 16 | COCOAPODS: 1.6.1 17 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # ActionSheetController 2 | ActionSheetController is an UIAlertController's APIs like ActionSheet control 3 | 4 | ### How does it look like? 5 | 6 |

7 |   8 |

9 | 10 | ### How to use 11 | 12 | ```swift 13 | let controller = ActionSheetController(cancelTitleColor: UIColor.blueColor()) 14 | 15 | let titles = ["发送给胖友", "收藏", "保存图片", "定位到聊天位置", "分享到微博", "复制链接", "复制图片"] 16 | titles.forEach { (title) -> () in 17 | let action = SheetAction(title: title, handler: { (sender: SheetAction) -> Void in 18 | debugPrint("Taped: \(sender.title)") 19 | }) 20 | controller.addAction(action) 21 | } 22 | 23 | let action = SheetAction(title: "Plus", titleColor: UIColor.redColor()) 24 | controller.addAction(action) 25 | 26 | presentViewController(controller, animated: true, completion: nil) 27 | ``` 28 | 29 | ### Notice 30 | 31 | - v0.x for swift 2.2 32 | - v1.x for swift2.3 33 | - v2.x for swift3.x 34 | - v3.x for swift4.x 35 | -------------------------------------------------------------------------------- /Sample/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.swift 3 | // Sample 4 | // 5 | // Created by Shaw on 3/10/16. 6 | // Copyright © 2016 Shaw. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | @UIApplicationMain 12 | class AppDelegate: UIResponder, UIApplicationDelegate { 13 | 14 | var window: UIWindow? 15 | 16 | 17 | func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { 18 | // Override point for customization after application launch. 19 | return true 20 | } 21 | 22 | func applicationWillResignActive(_ application: UIApplication) { 23 | // 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. 24 | // 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. 25 | } 26 | 27 | func applicationDidEnterBackground(_ application: UIApplication) { 28 | // 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. 29 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 30 | } 31 | 32 | func applicationWillEnterForeground(_ application: UIApplication) { 33 | // 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. 34 | } 35 | 36 | func applicationDidBecomeActive(_ application: UIApplication) { 37 | // 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. 38 | } 39 | 40 | func applicationWillTerminate(_ application: UIApplication) { 41 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 42 | } 43 | 44 | 45 | } 46 | 47 | -------------------------------------------------------------------------------- /Sample/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "29x29", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "29x29", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "40x40", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "40x40", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "60x60", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "60x60", 31 | "scale" : "3x" 32 | }, 33 | { 34 | "idiom" : "ipad", 35 | "size" : "29x29", 36 | "scale" : "1x" 37 | }, 38 | { 39 | "idiom" : "ipad", 40 | "size" : "29x29", 41 | "scale" : "2x" 42 | }, 43 | { 44 | "idiom" : "ipad", 45 | "size" : "40x40", 46 | "scale" : "1x" 47 | }, 48 | { 49 | "idiom" : "ipad", 50 | "size" : "40x40", 51 | "scale" : "2x" 52 | }, 53 | { 54 | "idiom" : "ipad", 55 | "size" : "76x76", 56 | "scale" : "1x" 57 | }, 58 | { 59 | "idiom" : "ipad", 60 | "size" : "76x76", 61 | "scale" : "2x" 62 | }, 63 | { 64 | "idiom" : "ipad", 65 | "size" : "83.5x83.5", 66 | "scale" : "2x" 67 | } 68 | ], 69 | "info" : { 70 | "version" : 1, 71 | "author" : "xcode" 72 | } 73 | } -------------------------------------------------------------------------------- /Sample/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 | -------------------------------------------------------------------------------- /Sample/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 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | -------------------------------------------------------------------------------- /Sample/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 | -------------------------------------------------------------------------------- /Sample/ViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.swift 3 | // Sample 4 | // 5 | // Created by Shaw on 3/10/16. 6 | // Copyright © 2016 Shaw. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | import ActionSheetController 11 | 12 | class ViewController: UIViewController { 13 | override func viewDidLoad() { 14 | super.viewDidLoad() 15 | // Do any additional setup after loading the view, typically from a nib. 16 | 17 | 18 | } 19 | 20 | override func touchesEnded(_ touches: Set, with event: UIEvent?) { 21 | super.touchesEnded(touches, with: event) 22 | let controller = ActionSheetController(title: "请选择以下其中一项 请选择以下其中一项请选择以下其中一项请选择以下其中一项请选择以下其中一项请选择以下其中一项请选择以下其中一项请选择以下其中一项", cancelTitleColor: UIColor.blue) 23 | // let controller = ActionSheetController(cancelTitleColor: UIColor.blue) 24 | let titles = ["发送给胖友", "收藏", "保存图片", "定位到聊天位置", "分享到微博", "复制链接", "复制图片"] 25 | // let titles = ["发送给胖友", "收藏", "保存图片"] 26 | titles.forEach { (title) -> () in 27 | let action = SheetAction(title: title) { (sender: SheetAction) in 28 | debugPrint("Taped: \(sender.title)") 29 | } 30 | controller.addAction(action) 31 | } 32 | 33 | let action = SheetAction(title: "Plus", titleColor: UIColor.red) 34 | controller.addAction(action) 35 | 36 | present(controller, animated: true, completion: nil) 37 | } 38 | 39 | } 40 | 41 | -------------------------------------------------------------------------------- /ScreenShoots/1.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cuzv/ActionSheetController/caba760b34eabbf473483ac3fd4e379d50759573/ScreenShoots/1.gif -------------------------------------------------------------------------------- /ScreenShoots/2.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cuzv/ActionSheetController/caba760b34eabbf473483ac3fd4e379d50759573/ScreenShoots/2.gif -------------------------------------------------------------------------------- /Sources/ActionSheetController.h: -------------------------------------------------------------------------------- 1 | // 2 | // ActionSheetController.h 3 | // ActionSheetController 4 | // 5 | // Created by Shaw on 3/10/16. 6 | // Copyright ©2016 Shaw. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | //! Project version number for ActionSheetController. 12 | FOUNDATION_EXPORT double ActionSheetControllerVersionNumber; 13 | 14 | //! Project version string for ActionSheetController. 15 | FOUNDATION_EXPORT const unsigned char ActionSheetControllerVersionString[]; 16 | 17 | // In this header, you should import all the public headers of your framework using statements like #import 18 | 19 | 20 | -------------------------------------------------------------------------------- /Sources/ActionSheetController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ActionSheetController.swift 3 | // ActionSheetController 4 | // 5 | // Created by Shaw on 3/10/16. 6 | // Copyright ©2016 Shaw (https://github.com/cuzv). 7 | // 8 | // Permission is hereby granted, free of charge, to any person obtaining a copy 9 | // of this software and associated documentation files (the "Software"), to deal 10 | // in the Software without restriction, including without limitation the rights 11 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | // copies of the Software, and to permit persons to whom the Software is 13 | // furnished to do so, subject to the following conditions: 14 | // 15 | // The above copyright notice and this permission notice shall be included in 16 | // all copies or substantial portions of the Software. 17 | // 18 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | // THE SOFTWARE. 25 | // 26 | 27 | import UIKit 28 | import ModalTransitioning 29 | 30 | public final class ActionSheetController: UIViewController { 31 | public private(set) var actions: [SheetAction] = [] 32 | 33 | private static let fixedRowHeight: CGFloat = 50 34 | 35 | private let contentTitle: String 36 | private let contentTitleColor: UIColor 37 | 38 | private let cancelTitle: String 39 | private let cancelTitleColor: UIColor 40 | 41 | private var containerViewHeightConstraint: NSLayoutConstraint! 42 | private var containerViewAppearedVerticalConstraint: NSLayoutConstraint! 43 | private var containerViewDisAppearedVerticalConstraint: NSLayoutConstraint! 44 | 45 | private lazy var modalTransitioningDelegate = ModalTransitioningDelegate(delegate: self) 46 | 47 | public init(title: String = "", titleColor: UIColor = .gray, cancelTitle: String = "Cancel", cancelTitleColor: UIColor = .black) { 48 | contentTitle = title 49 | contentTitleColor = titleColor 50 | self.cancelTitle = cancelTitle 51 | self.cancelTitleColor = cancelTitleColor 52 | super.init(nibName: nil, bundle: nil) 53 | modalPresentationStyle = .custom 54 | transitioningDelegate = modalTransitioningDelegate 55 | } 56 | 57 | required public init?(coder aDecoder: NSCoder) { 58 | fatalError("init(coder:) has not been implemented") 59 | } 60 | 61 | deinit { 62 | NotificationCenter.default.removeObserver(self) 63 | } 64 | 65 | private let labelBackedView: UIVisualEffectView = { 66 | let view = UIVisualEffectView(effect: UIBlurEffect(style: .extraLight)) 67 | view.translatesAutoresizingMaskIntoConstraints = false 68 | view.backgroundColor = UIColor.white.withAlphaComponent(0.8) 69 | return view 70 | }() 71 | 72 | private let topBorderline: UIView = { 73 | let view = UIView() 74 | view.translatesAutoresizingMaskIntoConstraints = false 75 | view.backgroundColor = UIColor.black.withAlphaComponent(0.25) 76 | return view 77 | }() 78 | 79 | private let titleLabel: UILabel = { 80 | let label = UILabel() 81 | label.textColor = UIColor.gray 82 | label.font = UIFont.preferredFont(forTextStyle: .subheadline) 83 | label.lineBreakMode = .byTruncatingTail 84 | label.numberOfLines = 0 85 | label.textAlignment = .center 86 | label.translatesAutoresizingMaskIntoConstraints = false 87 | return label 88 | }() 89 | 90 | private let tableView: UITableView = { 91 | let tableView = UITableView(frame: CGRect.zero, style: .plain) 92 | tableView.rowHeight = ActionSheetController.fixedRowHeight 93 | tableView.layoutMargins = UIEdgeInsets.zero 94 | tableView.separatorInset = UIEdgeInsets.zero 95 | tableView.tableFooterView = UIView(frame: CGRect(x: 0, y: 0, width: 0, height: CGFloat.leastNormalMagnitude)) 96 | tableView.alwaysBounceVertical = false 97 | tableView.translatesAutoresizingMaskIntoConstraints = false 98 | tableView.backgroundColor = UIColor.white.withAlphaComponent(0.8) 99 | return tableView 100 | }() 101 | 102 | private let cancelButton: UIButton = { 103 | let button = UIButton(type: .custom) 104 | button.translatesAutoresizingMaskIntoConstraints = false 105 | button.backgroundColor = UIColor.white.withAlphaComponent(0.8) 106 | button.setBackgroundImage(UIImageFrom(color: UIColor.black.withAlphaComponent(0.2)), for: .highlighted) 107 | return button 108 | }() 109 | 110 | private let containerView: UIVisualEffectView = { 111 | let view = UIVisualEffectView(effect: UIBlurEffect(style: .extraLight)) 112 | view.translatesAutoresizingMaskIntoConstraints = false 113 | return view 114 | }() 115 | 116 | private let coverView: UIView = { 117 | let view = UIView() 118 | view.backgroundColor = #colorLiteral(red: 0, green: 0, blue: 0, alpha: 0.5) 119 | view.translatesAutoresizingMaskIntoConstraints = false 120 | return view 121 | }() 122 | 123 | override public func viewDidLoad() { 124 | super.viewDidLoad() 125 | prepareConstraints() 126 | setupUserInterface() 127 | setupConstraints() 128 | NotificationCenter.default.addObserver(self, selector: #selector(handleChangeStatusBarOrientation(sender:)), name: UIApplication.didChangeStatusBarOrientationNotification, object: nil) 129 | } 130 | 131 | private func prepareConstraints() { 132 | containerViewAppearedVerticalConstraint = { 133 | if #available(iOS 11.0, *) { 134 | return containerView.bottomAnchor.constraint(equalTo: view.safeAreaLayoutGuide.bottomAnchor) 135 | } else { 136 | return NSLayoutConstraint( 137 | item: containerView, 138 | attribute: .bottom, 139 | relatedBy: .equal, 140 | toItem: view, 141 | attribute: .bottom, 142 | multiplier: 1, 143 | constant: 0 144 | ) 145 | } 146 | }() 147 | 148 | containerViewDisAppearedVerticalConstraint = { 149 | return NSLayoutConstraint( 150 | item: containerView, 151 | attribute: .top, 152 | relatedBy: .equal, 153 | toItem: view, 154 | attribute: .bottom, 155 | multiplier: 1, 156 | constant: 0 157 | ) 158 | }() 159 | } 160 | 161 | private func setupUserInterface() { 162 | titleLabel.text = contentTitle 163 | titleLabel.textColor = contentTitleColor 164 | 165 | cancelButton.setTitleColor(cancelTitleColor, for: []) 166 | cancelButton.setTitle(cancelTitle, for: []) 167 | cancelButton.addTarget(self, action: #selector(ActionSheetController._dismiss), for: .touchUpInside) 168 | 169 | view.addSubview(coverView) 170 | coverView.addGestureRecognizer(UITapGestureRecognizer(target: self, action: #selector(ActionSheetController.handleTapped(_:)))) 171 | 172 | view.addSubview(containerView) 173 | containerView.contentView.addSubview(cancelButton) 174 | containerView.contentView.addSubview(tableView) 175 | containerView.contentView.addSubview(labelBackedView) 176 | labelBackedView.contentView.addSubview(topBorderline) 177 | containerView.contentView.addSubview(titleLabel) 178 | 179 | tableView.register(ActionSheetCell.self, forCellReuseIdentifier: ActionSheetCell.identifier) 180 | tableView.delegate = self 181 | tableView.dataSource = self 182 | } 183 | 184 | private func setupConstraints() { 185 | // coverView 186 | view.addConstraints([ 187 | NSLayoutConstraint(item: coverView, attribute: .leading, relatedBy: .equal, toItem: view, attribute: .leading, multiplier: 1, constant: 0), 188 | NSLayoutConstraint(item: coverView, attribute: .trailing, relatedBy: .equal, toItem: view, attribute: .trailing, multiplier: 1, constant: 0), 189 | NSLayoutConstraint(item: coverView, attribute: .top, relatedBy: .equal, toItem: view, attribute: .top, multiplier: 1, constant: 0), 190 | NSLayoutConstraint(item: coverView, attribute: .bottom, relatedBy: .equal, toItem: view, attribute: .bottom, multiplier: 1, constant: 0) 191 | ]) 192 | 193 | // containerView 194 | view.addConstraints( 195 | NSLayoutConstraint.constraints( 196 | withVisualFormat: "|[containerView]|", 197 | options: [], 198 | metrics: nil, 199 | views: ["containerView": containerView] 200 | ) 201 | ) 202 | containerViewHeightConstraint = renewConstraint() 203 | view.addConstraints([ 204 | containerViewDisAppearedVerticalConstraint, 205 | containerViewHeightConstraint 206 | ]) 207 | 208 | // titleLabel 209 | if !contentTitle.isEmpty { 210 | containerView.addConstraints( 211 | NSLayoutConstraint.constraints( 212 | withVisualFormat: "|-16-[titleLabel]-16-|", 213 | options: [], 214 | metrics: nil, 215 | views: ["titleLabel": titleLabel] 216 | ) 217 | ) 218 | containerView.addConstraints([ 219 | NSLayoutConstraint( 220 | item: titleLabel, 221 | attribute: .top, 222 | relatedBy: .equal, 223 | toItem: containerView, 224 | attribute: .top, 225 | multiplier: 1, 226 | constant: 20 227 | ), 228 | NSLayoutConstraint( 229 | item: tableView, 230 | attribute: .top, 231 | relatedBy: .equal, 232 | toItem: titleLabel, 233 | attribute: .bottom, 234 | multiplier: 1, 235 | constant: 20 236 | ) 237 | ]) 238 | 239 | // labelBackedView 240 | containerView.addConstraints( 241 | NSLayoutConstraint.constraints( 242 | withVisualFormat: "|-0-[labelBackedView]-0-|", 243 | options: [], 244 | metrics: nil, 245 | views: ["labelBackedView": labelBackedView] 246 | ) 247 | ) 248 | containerView.addConstraints([ 249 | NSLayoutConstraint( 250 | item: labelBackedView, 251 | attribute: .top, 252 | relatedBy: .equal, 253 | toItem: containerView, 254 | attribute: .top, 255 | multiplier: 1, 256 | constant: 0 257 | ), 258 | NSLayoutConstraint( 259 | item: labelBackedView, 260 | attribute: .bottom, 261 | relatedBy: .equal, 262 | toItem: tableView, 263 | attribute: .top, 264 | multiplier: 1, 265 | constant: 0 266 | ) 267 | ]) 268 | 269 | // topBorderline 270 | labelBackedView.addConstraints( 271 | NSLayoutConstraint.constraints( 272 | withVisualFormat: "|-0-[topBorderline]-0-|", 273 | options: [], 274 | metrics: nil, 275 | views: ["topBorderline": topBorderline] 276 | ) 277 | ) 278 | labelBackedView.addConstraints([ 279 | NSLayoutConstraint( 280 | item: topBorderline, 281 | attribute: .height, 282 | relatedBy: .equal, 283 | toItem: nil, 284 | attribute: .notAnAttribute, 285 | multiplier: 1, 286 | constant: 1.0 / UIScreen.main.scale 287 | ), 288 | NSLayoutConstraint( 289 | item: topBorderline, 290 | attribute: .bottom, 291 | relatedBy: .equal, 292 | toItem: labelBackedView, 293 | attribute: .bottom, 294 | multiplier: 1, 295 | constant: 0 296 | ) 297 | ]) 298 | } else { 299 | containerView.addConstraints([ 300 | NSLayoutConstraint( 301 | item: tableView, 302 | attribute: .top, 303 | relatedBy: .equal, 304 | toItem: containerView, 305 | attribute: .top, 306 | multiplier: 1, 307 | constant: 0 308 | ) 309 | ]) 310 | } 311 | 312 | // tableView 313 | containerView.addConstraints( 314 | NSLayoutConstraint.constraints( 315 | withVisualFormat: "|[tableView]|", 316 | options: [], 317 | metrics: nil, 318 | views: ["tableView": tableView] 319 | ) 320 | ) 321 | containerView.addConstraints([ 322 | NSLayoutConstraint( 323 | item: tableView, 324 | attribute: .bottom, 325 | relatedBy: .equal, 326 | toItem: cancelButton, 327 | attribute: .top, 328 | multiplier: 1, 329 | constant: -6 330 | ) 331 | ]) 332 | 333 | // cancelButton 334 | containerView.addConstraints( 335 | NSLayoutConstraint.constraints( 336 | withVisualFormat: "|[cancelButton]|", 337 | options: [], 338 | metrics: nil, 339 | views: ["cancelButton": cancelButton] 340 | ) 341 | ) 342 | containerView.addConstraints([ 343 | NSLayoutConstraint( 344 | item: cancelButton, 345 | attribute: .bottom, 346 | relatedBy: .equal, 347 | toItem: containerView, 348 | attribute: .bottom, 349 | multiplier: 1, 350 | constant: 0 351 | ), 352 | NSLayoutConstraint( 353 | item: cancelButton, 354 | attribute: .height, 355 | relatedBy: .equal, 356 | toItem: nil, 357 | attribute: .notAnAttribute, 358 | multiplier: 0, 359 | constant: ActionSheetController.fixedRowHeight 360 | ) 361 | ]) 362 | } 363 | 364 | public override func updateViewConstraints() { 365 | view.removeConstraints([containerViewHeightConstraint]) 366 | containerViewHeightConstraint = renewConstraint() 367 | view.addConstraint(containerViewHeightConstraint) 368 | super.updateViewConstraints() 369 | } 370 | 371 | @objc func handleChangeStatusBarOrientation(sender: Notification) { 372 | updateViewConstraints() 373 | } 374 | 375 | internal func dismissWithCompletion(_ completion: (() -> Void)?) { 376 | presentingViewController?.dismiss(animated: true, completion: completion) 377 | } 378 | 379 | @objc private func handleTapped(_ sender: UITapGestureRecognizer) { 380 | if !containerView.frame.contains(sender.location(in: view)) { 381 | dismissWithCompletion(nil) 382 | } 383 | } 384 | 385 | @objc private func _dismiss() { 386 | dismissWithCompletion(nil) 387 | } 388 | 389 | public func addAction(_ action: SheetAction) { 390 | actions.append(action) 391 | } 392 | 393 | // MARK: - UI 394 | 395 | private func renewConstraint() -> NSLayoutConstraint { 396 | func containerViewHeight() -> CGFloat { 397 | // 计算文本高度 398 | var textHeight: CGFloat = 0 399 | if !contentTitle.isEmpty { 400 | textHeight = 40 401 | let width = view.bounds.width - 32 402 | let boundingRect = (contentTitle as NSString).boundingRect( 403 | with: CGSize(width: width, height: CGFloat.greatestFiniteMagnitude), 404 | options: [.usesLineFragmentOrigin, .usesFontLeading, .truncatesLastVisibleLine], 405 | attributes: [.font: titleLabel.font!], 406 | context: nil 407 | ) 408 | textHeight += boundingRect.size.height 409 | } 410 | let bottomHeight = ActionSheetController.fixedRowHeight + 6 // cancel + spacing 411 | let height = CGFloat(actions.count) * ActionSheetController.fixedRowHeight + textHeight 412 | let maxHeight = floor(view.bounds.height * CGFloat(0.67) / ActionSheetController.fixedRowHeight) * ActionSheetController.fixedRowHeight + textHeight 413 | return (height < maxHeight ? height : maxHeight) + bottomHeight 414 | } 415 | 416 | return NSLayoutConstraint( 417 | item: containerView, 418 | attribute: .height, 419 | relatedBy: .equal, 420 | toItem: nil, 421 | attribute: .notAnAttribute, 422 | multiplier: 0, 423 | constant: containerViewHeight() 424 | ) 425 | } 426 | } 427 | 428 | // MARK: - ModalTransitioning 429 | 430 | extension ActionSheetController: ModalTransitioning { 431 | public func runPresentAnimation(completion: @escaping (Bool) -> Void) { 432 | view.removeConstraint(containerViewDisAppearedVerticalConstraint) 433 | view.addConstraint(containerViewAppearedVerticalConstraint) 434 | coverView.alpha = 0 435 | 436 | UIView.animate(withDuration: presentDuration, delay: 0, options: .curveEaseInOut, animations: { 437 | self.view.layoutIfNeeded() 438 | self.coverView.alpha = 1 439 | }, completion: completion) 440 | } 441 | 442 | public func runDismissAnimation(completion: @escaping (Bool) -> Void) { 443 | view.removeConstraint(containerViewAppearedVerticalConstraint) 444 | view.addConstraint(containerViewDisAppearedVerticalConstraint) 445 | 446 | UIView.animate(withDuration: dismissDuration, delay: 0, options: .curveEaseInOut, animations: { 447 | self.view.layoutIfNeeded() 448 | self.coverView.alpha = 0 449 | }, completion: completion) 450 | } 451 | } 452 | 453 | // MARK: - Table view methods 454 | 455 | extension ActionSheetController: UITableViewDataSource { 456 | public func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { 457 | return actions.count 458 | } 459 | 460 | public func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { 461 | guard let cell = tableView.dequeueReusableCell(withIdentifier: ActionSheetCell.identifier, for: indexPath) as? ActionSheetCell else { 462 | fatalError("dequeue cell failure.") 463 | } 464 | 465 | cell.setupData(actions[(indexPath as NSIndexPath).row]) 466 | 467 | return cell 468 | } 469 | } 470 | 471 | extension ActionSheetController: UITableViewDelegate { 472 | public func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { 473 | tableView.deselectRow(at: indexPath, animated: true) 474 | 475 | let action = actions[(indexPath as NSIndexPath).row] 476 | dismissWithCompletion { () -> Void in 477 | action.handler?(action) 478 | } 479 | } 480 | } 481 | 482 | // MARK: - ActionSheetCell 483 | 484 | private final class ActionSheetCell: UITableViewCell { 485 | fileprivate static var identifier: String { 486 | return NSStringFromClass(self) 487 | } 488 | 489 | private let contentLabel: UILabel = { 490 | let label = UILabel() 491 | label.textColor = UIColor.black 492 | label.font = UIFont.preferredFont(forTextStyle: .body) 493 | label.textAlignment = .center 494 | label.translatesAutoresizingMaskIntoConstraints = false 495 | return label 496 | }() 497 | 498 | override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) { 499 | super.init(style: style, reuseIdentifier: reuseIdentifier) 500 | setupUserInterface() 501 | } 502 | 503 | required init?(coder aDecoder: NSCoder) { 504 | fatalError("init(coder:) has not been implemented") 505 | } 506 | 507 | private func setupUserInterface() { 508 | layoutMargins = UIEdgeInsets.zero 509 | separatorInset = UIEdgeInsets.zero 510 | backgroundColor = UIColor.clear 511 | contentView.backgroundColor = UIColor.clear 512 | selectedBackgroundView = { 513 | let view = UIView() 514 | view.backgroundColor = UIColor.black.withAlphaComponent(0.1) 515 | return view 516 | }() 517 | 518 | contentView.addSubview(contentLabel) 519 | 520 | let views = ["label": contentLabel] 521 | contentView.addConstraints( 522 | NSLayoutConstraint.constraints( 523 | withVisualFormat: "|-8-[label]-8-|", 524 | options: [], 525 | metrics: nil, 526 | views: views 527 | ) 528 | ) 529 | contentView.addConstraints( 530 | NSLayoutConstraint.constraints( 531 | withVisualFormat: "V:|[label]|", 532 | options: [], 533 | metrics: nil, 534 | views: views 535 | ) 536 | ) 537 | } 538 | 539 | fileprivate func setupData(_ action: SheetAction) { 540 | contentLabel.text = action.title 541 | contentLabel.textColor = action.titleColor 542 | } 543 | } 544 | 545 | private func UIImageFrom(color: UIColor, size: CGSize = CGSize(width: 1, height: 1)) -> UIImage? { 546 | UIGraphicsBeginImageContext(size) 547 | guard let context = UIGraphicsGetCurrentContext() else { 548 | return nil 549 | } 550 | context.setFillColor(color.cgColor) 551 | let rect = CGRect(x: 0, y: 0, width: size.width, height: size.height) 552 | context.fill(rect) 553 | let image = UIGraphicsGetImageFromCurrentImageContext() 554 | UIGraphicsEndImageContext() 555 | 556 | return image! 557 | } 558 | -------------------------------------------------------------------------------- /Sources/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 | -------------------------------------------------------------------------------- /Sources/SheetAction.swift: -------------------------------------------------------------------------------- 1 | // 2 | // SheetAction.swift 3 | // ActionSheetController 4 | // 5 | // Created by Shaw on 3/10/16. 6 | // Copyright ©2016 Shaw (https://github.com/cuzv). 7 | // 8 | // Permission is hereby granted, free of charge, to any person obtaining a copy 9 | // of this software and associated documentation files (the "Software"), to deal 10 | // in the Software without restriction, including without limitation the rights 11 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | // copies of the Software, and to permit persons to whom the Software is 13 | // furnished to do so, subject to the following conditions: 14 | // 15 | // The above copyright notice and this permission notice shall be included in 16 | // all copies or substantial portions of the Software. 17 | // 18 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | // THE SOFTWARE. 25 | // 26 | 27 | import UIKit 28 | 29 | public final class SheetAction { 30 | public let title: String 31 | public let titleColor: UIColor 32 | public let handler: ((SheetAction) -> Void)? 33 | 34 | public init(title: String, titleColor: UIColor = UIColor.black, handler: ((SheetAction) -> Void)? = nil) { 35 | self.title = title 36 | self.titleColor = titleColor 37 | self.handler = handler 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /Tests/ActionSheetControllerTests/ActionSheetControllerTests.swift: -------------------------------------------------------------------------------- 1 | import XCTest 2 | @testable import ActionSheetController 3 | 4 | final class ActionSheetControllerTests: XCTestCase { 5 | func testExample() { 6 | // This is an example of a functional test case. 7 | // Use XCTAssert and related functions to verify your tests produce the correct 8 | // results. 9 | } 10 | 11 | static var allTests = [ 12 | ("testExample", testExample), 13 | ] 14 | } 15 | -------------------------------------------------------------------------------- /Tests/ActionSheetControllerTests/XCTestManifests.swift: -------------------------------------------------------------------------------- 1 | import XCTest 2 | 3 | #if !canImport(ObjectiveC) 4 | public func allTests() -> [XCTestCaseEntry] { 5 | return [ 6 | testCase(ActionSheetControllerTests.allTests), 7 | ] 8 | } 9 | #endif 10 | -------------------------------------------------------------------------------- /Tests/LinuxMain.swift: -------------------------------------------------------------------------------- 1 | import XCTest 2 | 3 | import ActionSheetControllerTests 4 | 5 | var tests = [XCTestCaseEntry]() 6 | tests += ActionSheetControllerTests.allTests() 7 | XCTMain(tests) 8 | --------------------------------------------------------------------------------