├── .gitignore ├── DoActionSheet.podspec ├── LICENSE ├── README.md ├── Resource └── Images │ ├── pic1.jpg │ └── pic2.jpg ├── TestActionSheet.xcodeproj ├── project.pbxproj └── project.xcworkspace │ └── contents.xcworkspacedata ├── TestActionSheet ├── 3rdSource │ └── UIImage-ResizeMagick │ │ ├── .gitignore │ │ ├── LICENSE │ │ ├── README.md │ │ ├── UIImage+ResizeMagick.h │ │ ├── UIImage+ResizeMagick.m │ │ └── UIImage-ResizeMagick.podspec ├── AppDelegate.h ├── AppDelegate.m ├── Base.lproj │ └── Main.storyboard ├── DoActionSheet+Demo.h ├── DoActionSheet+Demo.m ├── DoActionSheet │ ├── DoActionSheet.h │ └── DoActionSheet.m ├── Images.xcassets │ ├── AppIcon.appiconset │ │ └── Contents.json │ └── LaunchImage.launchimage │ │ └── Contents.json ├── TestActionSheet-Info.plist ├── TestActionSheet-Prefix.pch ├── ViewController.h ├── ViewController.m ├── en.lproj │ └── InfoPlist.strings └── main.m ├── TestActionSheetTests ├── TestActionSheetTests-Info.plist ├── TestActionSheetTests.m └── en.lproj │ └── InfoPlist.strings ├── p1.png ├── p2.png ├── p3.png └── p4.png /.gitignore: -------------------------------------------------------------------------------- 1 | # Xcode 2 | .DS_Store 3 | */build/* 4 | *.pbxuser 5 | !default.pbxuser 6 | *.mode1v3 7 | !default.mode1v3 8 | *.mode2v3 9 | !default.mode2v3 10 | *.perspectivev3 11 | !default.perspectivev3 12 | xcuserdata 13 | profile 14 | *.moved-aside 15 | DerivedData 16 | .idea/ 17 | *.hmap 18 | *.xccheckout 19 | 20 | #CocoaPods 21 | Pods 22 | -------------------------------------------------------------------------------- /DoActionSheet.podspec: -------------------------------------------------------------------------------- 1 | Pod::Spec.new do |s| 2 | s.name = 'DoActionSheet' 3 | s.version = '1.0' 4 | s.author = { 'JackShi' => 'shiguifei@gmail.com' } 5 | s.homepage = 'https://github.com/donobono/DoActionSheet' 6 | s.summary = 'An replacement for UIActionSheet : block-based, customizable theme, easy to use with image or map' 7 | s.license = { :type => 'MIT', :file => 'License' } 8 | s.source = { :git => 'https://github.com/donobono/DoActionSheet.git', :tag => '1.0' } 9 | s.source_files = 'TestActionSheet/3rdSource/UIImage-ResizeMagick/*.{h,m}','TestActionSheet/DoActionSheet/*.{h,m}' 10 | s.platform = :ios 11 | s.requires_arc = true 12 | end 13 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2014 donobono 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of 6 | this software and associated documentation files (the "Software"), to deal in 7 | the Software without restriction, including without limitation the rights to 8 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 9 | the Software, and to permit persons to whom the Software is furnished to do so, 10 | 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, FITNESS 17 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 18 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 19 | IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 20 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | DoActionSheet 2 | ============= 3 | 4 | An replacement for UIActionSheet : block-based, customizable theme, easy to use with image or map 5 | 6 | ## Preview 7 | 8 | ### with title, with destructive button, with cancel button and with image 9 | ![DoAlertView Screenshot](https://raw.github.com/donobono/DoActionSheet/master/p1.png) 10 | 11 | ### support scroll if there are many buttons but cancel button’s position is fixed 12 | ![DoAlertView Screenshot](https://raw.github.com/donobono/DoActionSheet/master/p2.png) 13 | 14 | ### customizable color set 15 | ![DoAlertView Screenshot](https://raw.github.com/donobono/DoActionSheet/master/p3.png) 16 | 17 | ### with map 18 | ![DoAlertView Screenshot](https://raw.github.com/donobono/DoActionSheet/master/p4.png) 19 | 20 | 21 | ## Requirements 22 | - iOS 7.0 and greater 23 | - ARC 24 | 25 | 26 | ## Examples 27 | 28 | **Code:** 29 | 30 | ```objc 31 | 32 | DoActionSheet *vActionSheet = [[DoActionSheet alloc] init]; 33 | // required 34 | vActionSheet.nAnimationType = _sgType.selectedSegmentIndex; // there are 3 type of animation 35 | 36 | // optional 37 | vActionSheet.dButtonRound = 2; 38 | 39 | // with image 40 | vActionSheet.iImage = [UIImage imageNamed:@"pic1.jpg"]; 41 | vActionSheet.nContentMode = DoContentImage; 42 | 43 | 44 | // with map 45 | vActionSheet.nContentMode = DoContentMap; 46 | vActionSheet.dLocation = @{@"latitude" : @(37.78275123), @"longitude" : @(-122.40416442), @"altitude" : @200}; 47 | 48 | 49 | // launch DoActionSheet! - With destructive button, cancel button and title 50 | vActionSheet.nDestructiveIndex = 2; 51 | 52 | [vActionSheet showC:@"What do you want for this photo?" 53 | cancel:@"Cancel" 54 | buttons:@[@"Post to facebook", @"Post to Instagram", @"Delete this photo"] 55 | result:^(int nResult) { 56 | 57 | NSLog(@"---------------> result : %d", nResult); 58 | 59 | }]; 60 | 61 | 62 | // launch DoActionSheet! - With title and without cancel button 63 | [vActionSheet show:@"What do you want?" 64 | buttons:@[@"Open with Safari", @"Copy the link"] 65 | result:^(int nResult) { 66 | 67 | NSLog(@"---------------> result : %d", nResult); 68 | 69 | }]; 70 | 71 | ``` 72 | 73 | ```objc 74 | // customizable theme 75 | #define DO_BACK_COLOR DO_RGB(232, 229, 222) 76 | 77 | // button background color 78 | #define DO_BUTTON_COLOR DO_RGB(158, 132, 103) 79 | #define DO_CANCEL_COLOR DO_RGB(240, 185, 103) 80 | #define DO_DESTRUCTIVE_COLOR DO_RGB(124, 192, 134) 81 | 82 | // button text color 83 | #define DO_TITLE_TEXT_COLOR DO_RGB(95, 74, 50) 84 | #define DO_BUTTON_TEXT_COLOR DO_RGB(255, 255, 255) 85 | #define DO_CANCEL_TEXT_COLOR DO_RGB(255, 255, 255) 86 | #define DO_DESTRUCTIVE_TEXT_COLOR DO_RGB(255, 255, 255) 87 | ``` 88 | 89 | ## Credits 90 | 91 | DoActionSheet was created by Dono Cho. 92 | 93 | 94 | ## License 95 | 96 | DoActionSheet is available under the MIT license. See the LICENSE file for more info. 97 | -------------------------------------------------------------------------------- /Resource/Images/pic1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/donobono/DoActionSheet/f439e8653f484e196489104a4f815f114ff3ea2b/Resource/Images/pic1.jpg -------------------------------------------------------------------------------- /Resource/Images/pic2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/donobono/DoActionSheet/f439e8653f484e196489104a4f815f114ff3ea2b/Resource/Images/pic2.jpg -------------------------------------------------------------------------------- /TestActionSheet.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 04A8964E194AE7EE00EE8B44 /* DoActionSheet+Demo.m in Sources */ = {isa = PBXBuildFile; fileRef = 04A8964D194AE7EE00EE8B44 /* DoActionSheet+Demo.m */; }; 11 | 737FA50218750684008FA5AA /* .gitignore in Resources */ = {isa = PBXBuildFile; fileRef = 737FA4FC18750684008FA5AA /* .gitignore */; }; 12 | 737FA50318750684008FA5AA /* LICENSE in Resources */ = {isa = PBXBuildFile; fileRef = 737FA4FD18750684008FA5AA /* LICENSE */; }; 13 | 737FA50418750684008FA5AA /* README.md in Resources */ = {isa = PBXBuildFile; fileRef = 737FA4FE18750684008FA5AA /* README.md */; }; 14 | 737FA50518750684008FA5AA /* UIImage+ResizeMagick.m in Sources */ = {isa = PBXBuildFile; fileRef = 737FA50018750684008FA5AA /* UIImage+ResizeMagick.m */; }; 15 | 737FA50618750684008FA5AA /* UIImage-ResizeMagick.podspec in Resources */ = {isa = PBXBuildFile; fileRef = 737FA50118750684008FA5AA /* UIImage-ResizeMagick.podspec */; }; 16 | 737FA51B18750886008FA5AA /* pic1.jpg in Resources */ = {isa = PBXBuildFile; fileRef = 737FA51118750886008FA5AA /* pic1.jpg */; }; 17 | 737FA51C18750886008FA5AA /* pic2.jpg in Resources */ = {isa = PBXBuildFile; fileRef = 737FA51218750886008FA5AA /* pic2.jpg */; }; 18 | A5B9579B1873B38F0072554B /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A5B9579A1873B38F0072554B /* Foundation.framework */; }; 19 | A5B9579D1873B38F0072554B /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A5B9579C1873B38F0072554B /* CoreGraphics.framework */; }; 20 | A5B9579F1873B38F0072554B /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A5B9579E1873B38F0072554B /* UIKit.framework */; }; 21 | A5B957A51873B38F0072554B /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = A5B957A31873B38F0072554B /* InfoPlist.strings */; }; 22 | A5B957A71873B38F0072554B /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = A5B957A61873B38F0072554B /* main.m */; }; 23 | A5B957AB1873B38F0072554B /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = A5B957AA1873B38F0072554B /* AppDelegate.m */; }; 24 | A5B957AE1873B38F0072554B /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = A5B957AC1873B38F0072554B /* Main.storyboard */; }; 25 | A5B957B11873B38F0072554B /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = A5B957B01873B38F0072554B /* ViewController.m */; }; 26 | A5B957B31873B38F0072554B /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = A5B957B21873B38F0072554B /* Images.xcassets */; }; 27 | A5B957BA1873B38F0072554B /* XCTest.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A5B957B91873B38F0072554B /* XCTest.framework */; }; 28 | A5B957BB1873B38F0072554B /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A5B9579A1873B38F0072554B /* Foundation.framework */; }; 29 | A5B957BC1873B38F0072554B /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A5B9579E1873B38F0072554B /* UIKit.framework */; }; 30 | A5B957C41873B38F0072554B /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = A5B957C21873B38F0072554B /* InfoPlist.strings */; }; 31 | A5B957C61873B38F0072554B /* TestActionSheetTests.m in Sources */ = {isa = PBXBuildFile; fileRef = A5B957C51873B38F0072554B /* TestActionSheetTests.m */; }; 32 | A5B957DA1873C3EA0072554B /* DoActionSheet.m in Sources */ = {isa = PBXBuildFile; fileRef = A5B957D91873C3EA0072554B /* DoActionSheet.m */; }; 33 | /* End PBXBuildFile section */ 34 | 35 | /* Begin PBXContainerItemProxy section */ 36 | A5B957BD1873B38F0072554B /* PBXContainerItemProxy */ = { 37 | isa = PBXContainerItemProxy; 38 | containerPortal = A5B9578F1873B38F0072554B /* Project object */; 39 | proxyType = 1; 40 | remoteGlobalIDString = A5B957961873B38F0072554B; 41 | remoteInfo = TestActionSheet; 42 | }; 43 | /* End PBXContainerItemProxy section */ 44 | 45 | /* Begin PBXFileReference section */ 46 | 04A8964C194AE7EE00EE8B44 /* DoActionSheet+Demo.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "DoActionSheet+Demo.h"; sourceTree = ""; }; 47 | 04A8964D194AE7EE00EE8B44 /* DoActionSheet+Demo.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "DoActionSheet+Demo.m"; sourceTree = ""; }; 48 | 737FA4FC18750684008FA5AA /* .gitignore */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = .gitignore; sourceTree = ""; }; 49 | 737FA4FD18750684008FA5AA /* LICENSE */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = LICENSE; sourceTree = ""; }; 50 | 737FA4FE18750684008FA5AA /* README.md */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = README.md; sourceTree = ""; }; 51 | 737FA4FF18750684008FA5AA /* UIImage+ResizeMagick.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UIImage+ResizeMagick.h"; sourceTree = ""; }; 52 | 737FA50018750684008FA5AA /* UIImage+ResizeMagick.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UIImage+ResizeMagick.m"; sourceTree = ""; }; 53 | 737FA50118750684008FA5AA /* UIImage-ResizeMagick.podspec */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = "UIImage-ResizeMagick.podspec"; sourceTree = ""; }; 54 | 737FA51118750886008FA5AA /* pic1.jpg */ = {isa = PBXFileReference; lastKnownFileType = image.jpeg; path = pic1.jpg; sourceTree = ""; }; 55 | 737FA51218750886008FA5AA /* pic2.jpg */ = {isa = PBXFileReference; lastKnownFileType = image.jpeg; path = pic2.jpg; sourceTree = ""; }; 56 | A5B957971873B38F0072554B /* TestActionSheet.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = TestActionSheet.app; sourceTree = BUILT_PRODUCTS_DIR; }; 57 | A5B9579A1873B38F0072554B /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; }; 58 | A5B9579C1873B38F0072554B /* CoreGraphics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreGraphics.framework; path = System/Library/Frameworks/CoreGraphics.framework; sourceTree = SDKROOT; }; 59 | A5B9579E1873B38F0072554B /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; }; 60 | A5B957A21873B38F0072554B /* TestActionSheet-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "TestActionSheet-Info.plist"; sourceTree = ""; }; 61 | A5B957A41873B38F0072554B /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = ""; }; 62 | A5B957A61873B38F0072554B /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; 63 | A5B957A81873B38F0072554B /* TestActionSheet-Prefix.pch */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "TestActionSheet-Prefix.pch"; sourceTree = ""; }; 64 | A5B957A91873B38F0072554B /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; 65 | A5B957AA1873B38F0072554B /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; }; 66 | A5B957AD1873B38F0072554B /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 67 | A5B957AF1873B38F0072554B /* ViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ViewController.h; sourceTree = ""; }; 68 | A5B957B01873B38F0072554B /* ViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ViewController.m; sourceTree = ""; }; 69 | A5B957B21873B38F0072554B /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Images.xcassets; sourceTree = ""; }; 70 | A5B957B81873B38F0072554B /* TestActionSheetTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = TestActionSheetTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 71 | A5B957B91873B38F0072554B /* XCTest.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = XCTest.framework; path = Library/Frameworks/XCTest.framework; sourceTree = DEVELOPER_DIR; }; 72 | A5B957C11873B38F0072554B /* TestActionSheetTests-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "TestActionSheetTests-Info.plist"; sourceTree = ""; }; 73 | A5B957C31873B38F0072554B /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = ""; }; 74 | A5B957C51873B38F0072554B /* TestActionSheetTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = TestActionSheetTests.m; sourceTree = ""; }; 75 | A5B957D81873C3EA0072554B /* DoActionSheet.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DoActionSheet.h; sourceTree = ""; }; 76 | A5B957D91873C3EA0072554B /* DoActionSheet.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = DoActionSheet.m; sourceTree = ""; }; 77 | /* End PBXFileReference section */ 78 | 79 | /* Begin PBXFrameworksBuildPhase section */ 80 | A5B957941873B38F0072554B /* Frameworks */ = { 81 | isa = PBXFrameworksBuildPhase; 82 | buildActionMask = 2147483647; 83 | files = ( 84 | A5B9579D1873B38F0072554B /* CoreGraphics.framework in Frameworks */, 85 | A5B9579F1873B38F0072554B /* UIKit.framework in Frameworks */, 86 | A5B9579B1873B38F0072554B /* Foundation.framework in Frameworks */, 87 | ); 88 | runOnlyForDeploymentPostprocessing = 0; 89 | }; 90 | A5B957B51873B38F0072554B /* Frameworks */ = { 91 | isa = PBXFrameworksBuildPhase; 92 | buildActionMask = 2147483647; 93 | files = ( 94 | A5B957BA1873B38F0072554B /* XCTest.framework in Frameworks */, 95 | A5B957BC1873B38F0072554B /* UIKit.framework in Frameworks */, 96 | A5B957BB1873B38F0072554B /* Foundation.framework in Frameworks */, 97 | ); 98 | runOnlyForDeploymentPostprocessing = 0; 99 | }; 100 | /* End PBXFrameworksBuildPhase section */ 101 | 102 | /* Begin PBXGroup section */ 103 | 737FA4F918750684008FA5AA /* 3rdSource */ = { 104 | isa = PBXGroup; 105 | children = ( 106 | 737FA4FA18750684008FA5AA /* UIImage+Border */, 107 | 737FA4FB18750684008FA5AA /* UIImage-ResizeMagick */, 108 | ); 109 | path = 3rdSource; 110 | sourceTree = ""; 111 | }; 112 | 737FA4FA18750684008FA5AA /* UIImage+Border */ = { 113 | isa = PBXGroup; 114 | children = ( 115 | ); 116 | path = "UIImage+Border"; 117 | sourceTree = ""; 118 | }; 119 | 737FA4FB18750684008FA5AA /* UIImage-ResizeMagick */ = { 120 | isa = PBXGroup; 121 | children = ( 122 | 737FA4FC18750684008FA5AA /* .gitignore */, 123 | 737FA4FD18750684008FA5AA /* LICENSE */, 124 | 737FA4FE18750684008FA5AA /* README.md */, 125 | 737FA4FF18750684008FA5AA /* UIImage+ResizeMagick.h */, 126 | 737FA50018750684008FA5AA /* UIImage+ResizeMagick.m */, 127 | 737FA50118750684008FA5AA /* UIImage-ResizeMagick.podspec */, 128 | ); 129 | path = "UIImage-ResizeMagick"; 130 | sourceTree = ""; 131 | }; 132 | 737FA50718750886008FA5AA /* Resource */ = { 133 | isa = PBXGroup; 134 | children = ( 135 | 737FA50818750886008FA5AA /* Images */, 136 | ); 137 | path = Resource; 138 | sourceTree = SOURCE_ROOT; 139 | }; 140 | 737FA50818750886008FA5AA /* Images */ = { 141 | isa = PBXGroup; 142 | children = ( 143 | 737FA51118750886008FA5AA /* pic1.jpg */, 144 | 737FA51218750886008FA5AA /* pic2.jpg */, 145 | ); 146 | path = Images; 147 | sourceTree = ""; 148 | }; 149 | A5B9578E1873B38F0072554B = { 150 | isa = PBXGroup; 151 | children = ( 152 | A5B957A01873B38F0072554B /* TestActionSheet */, 153 | A5B957BF1873B38F0072554B /* TestActionSheetTests */, 154 | A5B957991873B38F0072554B /* Frameworks */, 155 | A5B957981873B38F0072554B /* Products */, 156 | ); 157 | sourceTree = ""; 158 | }; 159 | A5B957981873B38F0072554B /* Products */ = { 160 | isa = PBXGroup; 161 | children = ( 162 | A5B957971873B38F0072554B /* TestActionSheet.app */, 163 | A5B957B81873B38F0072554B /* TestActionSheetTests.xctest */, 164 | ); 165 | name = Products; 166 | sourceTree = ""; 167 | }; 168 | A5B957991873B38F0072554B /* Frameworks */ = { 169 | isa = PBXGroup; 170 | children = ( 171 | A5B9579A1873B38F0072554B /* Foundation.framework */, 172 | A5B9579C1873B38F0072554B /* CoreGraphics.framework */, 173 | A5B9579E1873B38F0072554B /* UIKit.framework */, 174 | A5B957B91873B38F0072554B /* XCTest.framework */, 175 | ); 176 | name = Frameworks; 177 | sourceTree = ""; 178 | }; 179 | A5B957A01873B38F0072554B /* TestActionSheet */ = { 180 | isa = PBXGroup; 181 | children = ( 182 | 737FA4F918750684008FA5AA /* 3rdSource */, 183 | A5B957D71873C3EA0072554B /* DoActionSheet */, 184 | A5B957A91873B38F0072554B /* AppDelegate.h */, 185 | A5B957AA1873B38F0072554B /* AppDelegate.m */, 186 | A5B957AC1873B38F0072554B /* Main.storyboard */, 187 | A5B957AF1873B38F0072554B /* ViewController.h */, 188 | A5B957B01873B38F0072554B /* ViewController.m */, 189 | 04A8964C194AE7EE00EE8B44 /* DoActionSheet+Demo.h */, 190 | 04A8964D194AE7EE00EE8B44 /* DoActionSheet+Demo.m */, 191 | A5B957B21873B38F0072554B /* Images.xcassets */, 192 | 737FA50718750886008FA5AA /* Resource */, 193 | A5B957A11873B38F0072554B /* Supporting Files */, 194 | ); 195 | path = TestActionSheet; 196 | sourceTree = ""; 197 | }; 198 | A5B957A11873B38F0072554B /* Supporting Files */ = { 199 | isa = PBXGroup; 200 | children = ( 201 | A5B957A21873B38F0072554B /* TestActionSheet-Info.plist */, 202 | A5B957A31873B38F0072554B /* InfoPlist.strings */, 203 | A5B957A61873B38F0072554B /* main.m */, 204 | A5B957A81873B38F0072554B /* TestActionSheet-Prefix.pch */, 205 | ); 206 | name = "Supporting Files"; 207 | sourceTree = ""; 208 | }; 209 | A5B957BF1873B38F0072554B /* TestActionSheetTests */ = { 210 | isa = PBXGroup; 211 | children = ( 212 | A5B957C51873B38F0072554B /* TestActionSheetTests.m */, 213 | A5B957C01873B38F0072554B /* Supporting Files */, 214 | ); 215 | path = TestActionSheetTests; 216 | sourceTree = ""; 217 | }; 218 | A5B957C01873B38F0072554B /* Supporting Files */ = { 219 | isa = PBXGroup; 220 | children = ( 221 | A5B957C11873B38F0072554B /* TestActionSheetTests-Info.plist */, 222 | A5B957C21873B38F0072554B /* InfoPlist.strings */, 223 | ); 224 | name = "Supporting Files"; 225 | sourceTree = ""; 226 | }; 227 | A5B957D71873C3EA0072554B /* DoActionSheet */ = { 228 | isa = PBXGroup; 229 | children = ( 230 | A5B957D81873C3EA0072554B /* DoActionSheet.h */, 231 | A5B957D91873C3EA0072554B /* DoActionSheet.m */, 232 | ); 233 | path = DoActionSheet; 234 | sourceTree = ""; 235 | }; 236 | /* End PBXGroup section */ 237 | 238 | /* Begin PBXNativeTarget section */ 239 | A5B957961873B38F0072554B /* TestActionSheet */ = { 240 | isa = PBXNativeTarget; 241 | buildConfigurationList = A5B957C91873B38F0072554B /* Build configuration list for PBXNativeTarget "TestActionSheet" */; 242 | buildPhases = ( 243 | A5B957931873B38F0072554B /* Sources */, 244 | A5B957941873B38F0072554B /* Frameworks */, 245 | A5B957951873B38F0072554B /* Resources */, 246 | ); 247 | buildRules = ( 248 | ); 249 | dependencies = ( 250 | ); 251 | name = TestActionSheet; 252 | productName = TestActionSheet; 253 | productReference = A5B957971873B38F0072554B /* TestActionSheet.app */; 254 | productType = "com.apple.product-type.application"; 255 | }; 256 | A5B957B71873B38F0072554B /* TestActionSheetTests */ = { 257 | isa = PBXNativeTarget; 258 | buildConfigurationList = A5B957CC1873B38F0072554B /* Build configuration list for PBXNativeTarget "TestActionSheetTests" */; 259 | buildPhases = ( 260 | A5B957B41873B38F0072554B /* Sources */, 261 | A5B957B51873B38F0072554B /* Frameworks */, 262 | A5B957B61873B38F0072554B /* Resources */, 263 | ); 264 | buildRules = ( 265 | ); 266 | dependencies = ( 267 | A5B957BE1873B38F0072554B /* PBXTargetDependency */, 268 | ); 269 | name = TestActionSheetTests; 270 | productName = TestActionSheetTests; 271 | productReference = A5B957B81873B38F0072554B /* TestActionSheetTests.xctest */; 272 | productType = "com.apple.product-type.bundle.unit-test"; 273 | }; 274 | /* End PBXNativeTarget section */ 275 | 276 | /* Begin PBXProject section */ 277 | A5B9578F1873B38F0072554B /* Project object */ = { 278 | isa = PBXProject; 279 | attributes = { 280 | LastUpgradeCheck = 0500; 281 | ORGANIZATIONNAME = "Dono Air"; 282 | TargetAttributes = { 283 | A5B957B71873B38F0072554B = { 284 | TestTargetID = A5B957961873B38F0072554B; 285 | }; 286 | }; 287 | }; 288 | buildConfigurationList = A5B957921873B38F0072554B /* Build configuration list for PBXProject "TestActionSheet" */; 289 | compatibilityVersion = "Xcode 3.2"; 290 | developmentRegion = English; 291 | hasScannedForEncodings = 0; 292 | knownRegions = ( 293 | en, 294 | Base, 295 | ); 296 | mainGroup = A5B9578E1873B38F0072554B; 297 | productRefGroup = A5B957981873B38F0072554B /* Products */; 298 | projectDirPath = ""; 299 | projectRoot = ""; 300 | targets = ( 301 | A5B957961873B38F0072554B /* TestActionSheet */, 302 | A5B957B71873B38F0072554B /* TestActionSheetTests */, 303 | ); 304 | }; 305 | /* End PBXProject section */ 306 | 307 | /* Begin PBXResourcesBuildPhase section */ 308 | A5B957951873B38F0072554B /* Resources */ = { 309 | isa = PBXResourcesBuildPhase; 310 | buildActionMask = 2147483647; 311 | files = ( 312 | 737FA50418750684008FA5AA /* README.md in Resources */, 313 | 737FA50218750684008FA5AA /* .gitignore in Resources */, 314 | 737FA51B18750886008FA5AA /* pic1.jpg in Resources */, 315 | 737FA51C18750886008FA5AA /* pic2.jpg in Resources */, 316 | A5B957B31873B38F0072554B /* Images.xcassets in Resources */, 317 | A5B957A51873B38F0072554B /* InfoPlist.strings in Resources */, 318 | 737FA50618750684008FA5AA /* UIImage-ResizeMagick.podspec in Resources */, 319 | A5B957AE1873B38F0072554B /* Main.storyboard in Resources */, 320 | 737FA50318750684008FA5AA /* LICENSE in Resources */, 321 | ); 322 | runOnlyForDeploymentPostprocessing = 0; 323 | }; 324 | A5B957B61873B38F0072554B /* Resources */ = { 325 | isa = PBXResourcesBuildPhase; 326 | buildActionMask = 2147483647; 327 | files = ( 328 | A5B957C41873B38F0072554B /* InfoPlist.strings in Resources */, 329 | ); 330 | runOnlyForDeploymentPostprocessing = 0; 331 | }; 332 | /* End PBXResourcesBuildPhase section */ 333 | 334 | /* Begin PBXSourcesBuildPhase section */ 335 | A5B957931873B38F0072554B /* Sources */ = { 336 | isa = PBXSourcesBuildPhase; 337 | buildActionMask = 2147483647; 338 | files = ( 339 | A5B957B11873B38F0072554B /* ViewController.m in Sources */, 340 | 04A8964E194AE7EE00EE8B44 /* DoActionSheet+Demo.m in Sources */, 341 | 737FA50518750684008FA5AA /* UIImage+ResizeMagick.m in Sources */, 342 | A5B957DA1873C3EA0072554B /* DoActionSheet.m in Sources */, 343 | A5B957AB1873B38F0072554B /* AppDelegate.m in Sources */, 344 | A5B957A71873B38F0072554B /* main.m in Sources */, 345 | ); 346 | runOnlyForDeploymentPostprocessing = 0; 347 | }; 348 | A5B957B41873B38F0072554B /* Sources */ = { 349 | isa = PBXSourcesBuildPhase; 350 | buildActionMask = 2147483647; 351 | files = ( 352 | A5B957C61873B38F0072554B /* TestActionSheetTests.m in Sources */, 353 | ); 354 | runOnlyForDeploymentPostprocessing = 0; 355 | }; 356 | /* End PBXSourcesBuildPhase section */ 357 | 358 | /* Begin PBXTargetDependency section */ 359 | A5B957BE1873B38F0072554B /* PBXTargetDependency */ = { 360 | isa = PBXTargetDependency; 361 | target = A5B957961873B38F0072554B /* TestActionSheet */; 362 | targetProxy = A5B957BD1873B38F0072554B /* PBXContainerItemProxy */; 363 | }; 364 | /* End PBXTargetDependency section */ 365 | 366 | /* Begin PBXVariantGroup section */ 367 | A5B957A31873B38F0072554B /* InfoPlist.strings */ = { 368 | isa = PBXVariantGroup; 369 | children = ( 370 | A5B957A41873B38F0072554B /* en */, 371 | ); 372 | name = InfoPlist.strings; 373 | sourceTree = ""; 374 | }; 375 | A5B957AC1873B38F0072554B /* Main.storyboard */ = { 376 | isa = PBXVariantGroup; 377 | children = ( 378 | A5B957AD1873B38F0072554B /* Base */, 379 | ); 380 | name = Main.storyboard; 381 | sourceTree = ""; 382 | }; 383 | A5B957C21873B38F0072554B /* InfoPlist.strings */ = { 384 | isa = PBXVariantGroup; 385 | children = ( 386 | A5B957C31873B38F0072554B /* en */, 387 | ); 388 | name = InfoPlist.strings; 389 | sourceTree = ""; 390 | }; 391 | /* End PBXVariantGroup section */ 392 | 393 | /* Begin XCBuildConfiguration section */ 394 | A5B957C71873B38F0072554B /* Debug */ = { 395 | isa = XCBuildConfiguration; 396 | buildSettings = { 397 | ALWAYS_SEARCH_USER_PATHS = NO; 398 | ARCHS = "$(ARCHS_STANDARD_INCLUDING_64_BIT)"; 399 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 400 | CLANG_CXX_LIBRARY = "libc++"; 401 | CLANG_ENABLE_MODULES = YES; 402 | CLANG_ENABLE_OBJC_ARC = YES; 403 | CLANG_WARN_BOOL_CONVERSION = YES; 404 | CLANG_WARN_CONSTANT_CONVERSION = YES; 405 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 406 | CLANG_WARN_EMPTY_BODY = YES; 407 | CLANG_WARN_ENUM_CONVERSION = YES; 408 | CLANG_WARN_INT_CONVERSION = YES; 409 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 410 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 411 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 412 | COPY_PHASE_STRIP = NO; 413 | GCC_C_LANGUAGE_STANDARD = gnu99; 414 | GCC_DYNAMIC_NO_PIC = NO; 415 | GCC_OPTIMIZATION_LEVEL = 0; 416 | GCC_PREPROCESSOR_DEFINITIONS = ( 417 | "DEBUG=1", 418 | "$(inherited)", 419 | ); 420 | GCC_SYMBOLS_PRIVATE_EXTERN = NO; 421 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 422 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 423 | GCC_WARN_UNDECLARED_SELECTOR = YES; 424 | GCC_WARN_UNINITIALIZED_AUTOS = YES; 425 | GCC_WARN_UNUSED_FUNCTION = YES; 426 | GCC_WARN_UNUSED_VARIABLE = YES; 427 | IPHONEOS_DEPLOYMENT_TARGET = 7.0; 428 | ONLY_ACTIVE_ARCH = YES; 429 | SDKROOT = iphoneos; 430 | }; 431 | name = Debug; 432 | }; 433 | A5B957C81873B38F0072554B /* Release */ = { 434 | isa = XCBuildConfiguration; 435 | buildSettings = { 436 | ALWAYS_SEARCH_USER_PATHS = NO; 437 | ARCHS = "$(ARCHS_STANDARD_INCLUDING_64_BIT)"; 438 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 439 | CLANG_CXX_LIBRARY = "libc++"; 440 | CLANG_ENABLE_MODULES = YES; 441 | CLANG_ENABLE_OBJC_ARC = YES; 442 | CLANG_WARN_BOOL_CONVERSION = YES; 443 | CLANG_WARN_CONSTANT_CONVERSION = YES; 444 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 445 | CLANG_WARN_EMPTY_BODY = YES; 446 | CLANG_WARN_ENUM_CONVERSION = YES; 447 | CLANG_WARN_INT_CONVERSION = YES; 448 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 449 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 450 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 451 | COPY_PHASE_STRIP = YES; 452 | ENABLE_NS_ASSERTIONS = NO; 453 | GCC_C_LANGUAGE_STANDARD = gnu99; 454 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 455 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 456 | GCC_WARN_UNDECLARED_SELECTOR = YES; 457 | GCC_WARN_UNINITIALIZED_AUTOS = YES; 458 | GCC_WARN_UNUSED_FUNCTION = YES; 459 | GCC_WARN_UNUSED_VARIABLE = YES; 460 | IPHONEOS_DEPLOYMENT_TARGET = 7.0; 461 | SDKROOT = iphoneos; 462 | VALIDATE_PRODUCT = YES; 463 | }; 464 | name = Release; 465 | }; 466 | A5B957CA1873B38F0072554B /* Debug */ = { 467 | isa = XCBuildConfiguration; 468 | buildSettings = { 469 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 470 | ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage; 471 | GCC_PRECOMPILE_PREFIX_HEADER = YES; 472 | GCC_PREFIX_HEADER = "TestActionSheet/TestActionSheet-Prefix.pch"; 473 | INFOPLIST_FILE = "TestActionSheet/TestActionSheet-Info.plist"; 474 | IPHONEOS_DEPLOYMENT_TARGET = 6.0; 475 | PRODUCT_NAME = "$(TARGET_NAME)"; 476 | WRAPPER_EXTENSION = app; 477 | }; 478 | name = Debug; 479 | }; 480 | A5B957CB1873B38F0072554B /* Release */ = { 481 | isa = XCBuildConfiguration; 482 | buildSettings = { 483 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 484 | ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage; 485 | GCC_PRECOMPILE_PREFIX_HEADER = YES; 486 | GCC_PREFIX_HEADER = "TestActionSheet/TestActionSheet-Prefix.pch"; 487 | INFOPLIST_FILE = "TestActionSheet/TestActionSheet-Info.plist"; 488 | IPHONEOS_DEPLOYMENT_TARGET = 6.0; 489 | PRODUCT_NAME = "$(TARGET_NAME)"; 490 | WRAPPER_EXTENSION = app; 491 | }; 492 | name = Release; 493 | }; 494 | A5B957CD1873B38F0072554B /* Debug */ = { 495 | isa = XCBuildConfiguration; 496 | buildSettings = { 497 | ARCHS = "$(ARCHS_STANDARD_INCLUDING_64_BIT)"; 498 | BUNDLE_LOADER = "$(BUILT_PRODUCTS_DIR)/TestActionSheet.app/TestActionSheet"; 499 | FRAMEWORK_SEARCH_PATHS = ( 500 | "$(SDKROOT)/Developer/Library/Frameworks", 501 | "$(inherited)", 502 | "$(DEVELOPER_FRAMEWORKS_DIR)", 503 | ); 504 | GCC_PRECOMPILE_PREFIX_HEADER = YES; 505 | GCC_PREFIX_HEADER = "TestActionSheet/TestActionSheet-Prefix.pch"; 506 | GCC_PREPROCESSOR_DEFINITIONS = ( 507 | "DEBUG=1", 508 | "$(inherited)", 509 | ); 510 | INFOPLIST_FILE = "TestActionSheetTests/TestActionSheetTests-Info.plist"; 511 | PRODUCT_NAME = "$(TARGET_NAME)"; 512 | TEST_HOST = "$(BUNDLE_LOADER)"; 513 | WRAPPER_EXTENSION = xctest; 514 | }; 515 | name = Debug; 516 | }; 517 | A5B957CE1873B38F0072554B /* Release */ = { 518 | isa = XCBuildConfiguration; 519 | buildSettings = { 520 | ARCHS = "$(ARCHS_STANDARD_INCLUDING_64_BIT)"; 521 | BUNDLE_LOADER = "$(BUILT_PRODUCTS_DIR)/TestActionSheet.app/TestActionSheet"; 522 | FRAMEWORK_SEARCH_PATHS = ( 523 | "$(SDKROOT)/Developer/Library/Frameworks", 524 | "$(inherited)", 525 | "$(DEVELOPER_FRAMEWORKS_DIR)", 526 | ); 527 | GCC_PRECOMPILE_PREFIX_HEADER = YES; 528 | GCC_PREFIX_HEADER = "TestActionSheet/TestActionSheet-Prefix.pch"; 529 | INFOPLIST_FILE = "TestActionSheetTests/TestActionSheetTests-Info.plist"; 530 | PRODUCT_NAME = "$(TARGET_NAME)"; 531 | TEST_HOST = "$(BUNDLE_LOADER)"; 532 | WRAPPER_EXTENSION = xctest; 533 | }; 534 | name = Release; 535 | }; 536 | /* End XCBuildConfiguration section */ 537 | 538 | /* Begin XCConfigurationList section */ 539 | A5B957921873B38F0072554B /* Build configuration list for PBXProject "TestActionSheet" */ = { 540 | isa = XCConfigurationList; 541 | buildConfigurations = ( 542 | A5B957C71873B38F0072554B /* Debug */, 543 | A5B957C81873B38F0072554B /* Release */, 544 | ); 545 | defaultConfigurationIsVisible = 0; 546 | defaultConfigurationName = Release; 547 | }; 548 | A5B957C91873B38F0072554B /* Build configuration list for PBXNativeTarget "TestActionSheet" */ = { 549 | isa = XCConfigurationList; 550 | buildConfigurations = ( 551 | A5B957CA1873B38F0072554B /* Debug */, 552 | A5B957CB1873B38F0072554B /* Release */, 553 | ); 554 | defaultConfigurationIsVisible = 0; 555 | defaultConfigurationName = Release; 556 | }; 557 | A5B957CC1873B38F0072554B /* Build configuration list for PBXNativeTarget "TestActionSheetTests" */ = { 558 | isa = XCConfigurationList; 559 | buildConfigurations = ( 560 | A5B957CD1873B38F0072554B /* Debug */, 561 | A5B957CE1873B38F0072554B /* Release */, 562 | ); 563 | defaultConfigurationIsVisible = 0; 564 | defaultConfigurationName = Release; 565 | }; 566 | /* End XCConfigurationList section */ 567 | }; 568 | rootObject = A5B9578F1873B38F0072554B /* Project object */; 569 | } 570 | -------------------------------------------------------------------------------- /TestActionSheet.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /TestActionSheet/3rdSource/UIImage-ResizeMagick/.gitignore: -------------------------------------------------------------------------------- 1 | # Xcode 2 | .DS_Store 3 | build/ 4 | *.pbxuser 5 | !default.pbxuser 6 | *.mode1v3 7 | !default.mode1v3 8 | *.mode2v3 9 | !default.mode2v3 10 | *.perspectivev3 11 | !default.perspectivev3 12 | *.xcworkspace 13 | !default.xcworkspace 14 | xcuserdata 15 | profile 16 | *.moved-aside 17 | DerivedData 18 | .idea/ 19 | -------------------------------------------------------------------------------- /TestActionSheet/3rdSource/UIImage-ResizeMagick/LICENSE: -------------------------------------------------------------------------------- 1 | Without any further information, all the sources provided here are under the MIT License 2 | quoted below. 3 | 4 | Anyway, please contact me by email (vlad.andersen@gmail.com) if you plan to use my work and the provided classes 5 | in your own software. Thanks. 6 | 7 | 8 | /*********************************************************************************** 9 | * 10 | * Copyright (c) 2013 Vlad Andersen 11 | * 12 | * Permission is hereby granted, free of charge, to any person obtaining a copy 13 | * of this software and associated documentation files (the "Software"), to deal 14 | * in the Software without restriction, including without limitation the rights 15 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 16 | * copies of the Software, and to permit persons to whom the Software is 17 | * furnished to do so, subject to the following conditions: 18 | * 19 | * The above copyright notice and this permission notice shall be included in 20 | * all copies or substantial portions of the Software. 21 | * 22 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 23 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 24 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 25 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 26 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 27 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 28 | * THE SOFTWARE. 29 | * 30 | *********************************************************************************** 31 | * 32 | * Any comment or suggestion welcome. Referencing this project in your AboutBox is appreciated. 33 | * Please tell me if you use this class so we can cross-reference our projects. 34 | * 35 | ***********************************************************************************/ 36 | -------------------------------------------------------------------------------- /TestActionSheet/3rdSource/UIImage-ResizeMagick/README.md: -------------------------------------------------------------------------------- 1 | UIImage-Resize (Magick!) 2 | ======================== 3 | 4 | Resizing UIImage on iOS should be simple. This category provides a simple, yet flexible syntax to resize any image to your needs. 5 | 6 | ```objective-c 7 | - (UIImage *) resizedImageByMagick: (NSString *) spec; 8 | ``` 9 | 10 | where **spec** could be one of the following expressions (follows ImageMagick syntax conventions): 11 | 12 | - [width] -- resize by width, height automatically selected to preserve aspect ratio. 13 | - x[height] -- resize by height, width automagically selected to preserve aspect ratio. 14 | - [width]x[height] -- maximum values of height and width given, aspect ratio preserved. 15 | - [width]x[height]^ -- minimum values of height and width given, aspect ratio preserved. 16 | - [width]x[height]! -- width and height emphatically given, original aspect ratio ignored. 17 | - [width]x[height]# -- scale and crop to exactly that size, original aspect ratio preserved (you probably want this one for your thumbnails). 18 | 19 | Example: 20 | 21 | ```objective-c 22 | UIImage* resizedImage = [image resizedImageByMagick: @"320x320#"]; 23 | ``` 24 | 25 | Caveat 26 | ------ 27 | 28 | There is some support for orientations (not mirrored still). There is no support for scale (do we need it?), so please define pixel values. 29 | 30 | The project uses ARC, so you should compile UIImage-Resize.m with ```-fobjc-arc``` if your project is not using ARC. 31 | 32 | Additional methods: 33 | ------------------- 34 | 35 | If you need some resizing with data known on-the-fly, this category defines the following additional methods: 36 | 37 | ```objective-c 38 | - (UIImage *) resizedImageByWidth: (NSUInteger) width; 39 | - (UIImage *) resizedImageByHeight: (NSUInteger) height; 40 | - (UIImage *) resizedImageWithMaximumSize: (CGSize) size; 41 | - (UIImage *) resizedImageWithMinimumSize: (CGSize) size; 42 | ``` 43 | -------------------------------------------------------------------------------- /TestActionSheet/3rdSource/UIImage-ResizeMagick/UIImage+ResizeMagick.h: -------------------------------------------------------------------------------- 1 | // 2 | // UIImage+ResizeMagick.h 3 | // 4 | // 5 | // Created by Vlad Andersen on 1/5/13. 6 | // 7 | // 8 | 9 | 10 | 11 | @interface UIImage (ResizeMagick) 12 | 13 | - (UIImage *) resizedImageByMagick: (NSString *) spec; 14 | - (UIImage *) resizedImageByWidth: (NSUInteger) width; 15 | - (UIImage *) resizedImageByHeight: (NSUInteger) height; 16 | - (UIImage *) resizedImageWithMaximumSize: (CGSize) size; 17 | - (UIImage *) resizedImageWithMinimumSize: (CGSize) size; 18 | 19 | @end 20 | -------------------------------------------------------------------------------- /TestActionSheet/3rdSource/UIImage-ResizeMagick/UIImage+ResizeMagick.m: -------------------------------------------------------------------------------- 1 | // 2 | // UIImage+ResizeMagick.m 3 | // 4 | // 5 | // Created by Vlad Andersen on 1/5/13. 6 | // 7 | // 8 | 9 | #import "UIImage+ResizeMagick.h" 10 | 11 | @implementation UIImage (ResizeMagick) 12 | 13 | // width Width given, height automagically selected to preserve aspect ratio. 14 | // xheight Height given, width automagically selected to preserve aspect ratio. 15 | // widthxheight Maximum values of height and width given, aspect ratio preserved. 16 | // widthxheight^ Minimum values of width and height given, aspect ratio preserved. 17 | // widthxheight! Exact dimensions, no aspect ratio preserved. 18 | // widthxheight# Crop to this exact dimensions. 19 | 20 | - (UIImage *) resizedImageByMagick: (NSString *) spec 21 | { 22 | 23 | if([spec hasSuffix:@"!"]) { 24 | NSString *specWithoutSuffix = [spec substringToIndex: [spec length] - 1]; 25 | NSArray *widthAndHeight = [specWithoutSuffix componentsSeparatedByString: @"x"]; 26 | NSUInteger width = [[widthAndHeight objectAtIndex: 0] longLongValue]; 27 | NSUInteger height = [[widthAndHeight objectAtIndex: 1] longLongValue]; 28 | UIImage *newImage = [self resizedImageWithMinimumSize: CGSizeMake (width, height)]; 29 | return [newImage drawImageInBounds: CGRectMake (0, 0, width, height)]; 30 | } 31 | 32 | if([spec hasSuffix:@"#"]) { 33 | NSString *specWithoutSuffix = [spec substringToIndex: [spec length] - 1]; 34 | NSArray *widthAndHeight = [specWithoutSuffix componentsSeparatedByString: @"x"]; 35 | NSUInteger width = [[widthAndHeight objectAtIndex: 0] longLongValue]; 36 | NSUInteger height = [[widthAndHeight objectAtIndex: 1] longLongValue]; 37 | UIImage *newImage = [self resizedImageWithMinimumSize: CGSizeMake (width, height)]; 38 | return [newImage croppedImageWithRect: CGRectMake ((newImage.size.width - width) / 2, (newImage.size.height - height) / 2, width, height)]; 39 | } 40 | 41 | if([spec hasSuffix:@"^"]) { 42 | NSString *specWithoutSuffix = [spec substringToIndex: [spec length] - 1]; 43 | NSArray *widthAndHeight = [specWithoutSuffix componentsSeparatedByString: @"x"]; 44 | return [self resizedImageWithMinimumSize: CGSizeMake ([[widthAndHeight objectAtIndex: 0] longLongValue], 45 | [[widthAndHeight objectAtIndex: 1] longLongValue])]; 46 | } 47 | 48 | NSArray *widthAndHeight = [spec componentsSeparatedByString: @"x"]; 49 | if ([widthAndHeight count] == 1) { 50 | return [self resizedImageByWidth: [spec longLongValue]]; 51 | } 52 | if ([[widthAndHeight objectAtIndex: 0] isEqualToString: @""]) { 53 | return [self resizedImageByHeight: [[widthAndHeight objectAtIndex: 1] longLongValue]]; 54 | } 55 | return [self resizedImageWithMaximumSize: CGSizeMake ([[widthAndHeight objectAtIndex: 0] longLongValue], 56 | [[widthAndHeight objectAtIndex: 1] longLongValue])]; 57 | } 58 | 59 | - (CGImageRef) CGImageWithCorrectOrientation 60 | { 61 | if (self.imageOrientation == UIImageOrientationDown) { 62 | //retaining because caller expects to own the reference 63 | CGImageRetain([self CGImage]); 64 | return [self CGImage]; 65 | } 66 | UIGraphicsBeginImageContext(self.size); 67 | 68 | CGContextRef context = UIGraphicsGetCurrentContext(); 69 | 70 | if (self.imageOrientation == UIImageOrientationRight) { 71 | CGContextRotateCTM (context, 90 * M_PI/180); 72 | } else if (self.imageOrientation == UIImageOrientationLeft) { 73 | CGContextRotateCTM (context, -90 * M_PI/180); 74 | } else if (self.imageOrientation == UIImageOrientationUp) { 75 | CGContextRotateCTM (context, 180 * M_PI/180); 76 | } 77 | 78 | [self drawAtPoint:CGPointMake(0, 0)]; 79 | 80 | CGImageRef cgImage = CGBitmapContextCreateImage(context); 81 | UIGraphicsEndImageContext(); 82 | 83 | return cgImage; 84 | } 85 | 86 | 87 | - (UIImage *) resizedImageByWidth: (NSUInteger) width 88 | { 89 | CGImageRef imgRef = [self CGImageWithCorrectOrientation]; 90 | CGFloat original_width = CGImageGetWidth(imgRef); 91 | CGFloat original_height = CGImageGetHeight(imgRef); 92 | CGFloat ratio = width/original_width; 93 | CGImageRelease(imgRef); 94 | return [self drawImageInBounds: CGRectMake(0, 0, width, round(original_height * ratio))]; 95 | } 96 | 97 | - (UIImage *) resizedImageByHeight: (NSUInteger) height 98 | { 99 | CGImageRef imgRef = [self CGImageWithCorrectOrientation]; 100 | CGFloat original_width = CGImageGetWidth(imgRef); 101 | CGFloat original_height = CGImageGetHeight(imgRef); 102 | CGFloat ratio = height/original_height; 103 | CGImageRelease(imgRef); 104 | return [self drawImageInBounds: CGRectMake(0, 0, round(original_width * ratio), height)]; 105 | } 106 | 107 | - (UIImage *) resizedImageWithMinimumSize: (CGSize) size 108 | { 109 | CGImageRef imgRef = [self CGImageWithCorrectOrientation]; 110 | CGFloat original_width = CGImageGetWidth(imgRef); 111 | CGFloat original_height = CGImageGetHeight(imgRef); 112 | CGFloat width_ratio = size.width / original_width; 113 | CGFloat height_ratio = size.height / original_height; 114 | CGFloat scale_ratio = width_ratio > height_ratio ? width_ratio : height_ratio; 115 | CGImageRelease(imgRef); 116 | return [self drawImageInBounds: CGRectMake(0, 0, round(original_width * scale_ratio), round(original_height * scale_ratio))]; 117 | } 118 | 119 | - (UIImage *) resizedImageWithMaximumSize: (CGSize) size 120 | { 121 | CGImageRef imgRef = [self CGImageWithCorrectOrientation]; 122 | CGFloat original_width = CGImageGetWidth(imgRef); 123 | CGFloat original_height = CGImageGetHeight(imgRef); 124 | CGFloat width_ratio = size.width / original_width; 125 | CGFloat height_ratio = size.height / original_height; 126 | CGFloat scale_ratio = width_ratio < height_ratio ? width_ratio : height_ratio; 127 | CGImageRelease(imgRef); 128 | return [self drawImageInBounds: CGRectMake(0, 0, round(original_width * scale_ratio), round(original_height * scale_ratio))]; 129 | } 130 | 131 | - (UIImage *) drawImageInBounds: (CGRect) bounds 132 | { 133 | UIGraphicsBeginImageContext(bounds.size); 134 | [self drawInRect: bounds]; 135 | UIImage *resizedImage = UIGraphicsGetImageFromCurrentImageContext(); 136 | UIGraphicsEndImageContext(); 137 | return resizedImage; 138 | } 139 | 140 | - (UIImage*) croppedImageWithRect: (CGRect) rect { 141 | 142 | UIGraphicsBeginImageContext(rect.size); 143 | CGContextRef context = UIGraphicsGetCurrentContext(); 144 | CGRect drawRect = CGRectMake(-rect.origin.x, -rect.origin.y, self.size.width, self.size.height); 145 | CGContextClipToRect(context, CGRectMake(0, 0, rect.size.width, rect.size.height)); 146 | [self drawInRect:drawRect]; 147 | UIImage* subImage = UIGraphicsGetImageFromCurrentImageContext(); 148 | UIGraphicsEndImageContext(); 149 | 150 | return subImage; 151 | } 152 | 153 | 154 | @end 155 | -------------------------------------------------------------------------------- /TestActionSheet/3rdSource/UIImage-ResizeMagick/UIImage-ResizeMagick.podspec: -------------------------------------------------------------------------------- 1 | Pod::Spec.new do |s| 2 | 3 | s.name = "UIImage-ResizeMagick" 4 | s.version = "0.0.1" 5 | s.summary = "Resizing UIImage on iOS. ImageMagick-style." 6 | 7 | s.description = <<-DESC 8 | Resizing UIImage on iOS should be simple. This category 9 | provides a simple, yet flexible syntax to resize any image 10 | to your needs. 11 | 12 | - (UIImage *) resizedImageByMagick: (NSString *) spec; 13 | 14 | where spec conforms to the ImageMagick syntax conventions 15 | (think Paperclip). 16 | 17 | UIImage* resizedImage = [image resizedImageByMagick: @"320x320#"]; 18 | DESC 19 | 20 | s.homepage = "https://github.com/mustangostang/UIImage-ResizeMagick" 21 | s.license = 'MIT' 22 | 23 | s.author = { "Vlad Andersen" => "vlad.andersen@gmail.com" } 24 | s.platform = :ios, '5.0' 25 | 26 | s.source = { :git => "https://github.com/mustangostang/UIImage-ResizeMagick.git", :tag => "0.0.1" } 27 | s.source_files = '*.{h,m}' 28 | s.requires_arc = true 29 | 30 | end 31 | -------------------------------------------------------------------------------- /TestActionSheet/AppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.h 3 | // TestActionSheet 4 | // 5 | // Created by Dono Air on 2014. 1. 1.. 6 | // Copyright (c) 2014년 Dono Air. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface AppDelegate : UIResponder 12 | 13 | @property (strong, nonatomic) UIWindow *window; 14 | 15 | @end 16 | -------------------------------------------------------------------------------- /TestActionSheet/AppDelegate.m: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.m 3 | // TestActionSheet 4 | // 5 | // Created by Dono Air on 2014. 1. 1.. 6 | // Copyright (c) 2014년 Dono Air. All rights reserved. 7 | // 8 | 9 | #import "AppDelegate.h" 10 | 11 | @implementation AppDelegate 12 | 13 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions 14 | { 15 | // Override point for customization after application launch. 16 | return YES; 17 | } 18 | 19 | - (void)applicationWillResignActive:(UIApplication *)application 20 | { 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 throttle down OpenGL ES frame rates. Games should use this method to pause the game. 23 | } 24 | 25 | - (void)applicationDidEnterBackground:(UIApplication *)application 26 | { 27 | // 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. 28 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 29 | } 30 | 31 | - (void)applicationWillEnterForeground:(UIApplication *)application 32 | { 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 | - (void)applicationDidBecomeActive:(UIApplication *)application 37 | { 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 | { 43 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 44 | } 45 | 46 | @end 47 | -------------------------------------------------------------------------------- /TestActionSheet/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 | 46 | 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 | 84 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | -------------------------------------------------------------------------------- /TestActionSheet/DoActionSheet+Demo.h: -------------------------------------------------------------------------------- 1 | // 2 | // DoActionSheet+Demo.h 3 | // TestActionSheet 4 | // 5 | // Created by Jack Shi on 13/06/2014. 6 | // Copyright (c) 2014 Dono Air. All rights reserved. 7 | // 8 | 9 | #import "DoActionSheet.h" 10 | 11 | @interface DoActionSheet (Demo) 12 | 13 | - (void)setStyle1; 14 | - (void)setStyle2; 15 | - (void)setStyle3; 16 | 17 | @end 18 | -------------------------------------------------------------------------------- /TestActionSheet/DoActionSheet+Demo.m: -------------------------------------------------------------------------------- 1 | // 2 | // DoActionSheet+Demo.m 3 | // TestActionSheet 4 | // 5 | // Created by Jack Shi on 13/06/2014. 6 | // Copyright (c) 2014 Dono Air. All rights reserved. 7 | // 8 | 9 | #import "DoActionSheet+Demo.h" 10 | 11 | @implementation DoActionSheet (Demo) 12 | 13 | - (id)init 14 | { 15 | self = [super init]; 16 | if (self) 17 | { 18 | // set default style 19 | [self setDefaultStyle]; 20 | } 21 | return self; 22 | } 23 | 24 | - (void)setDefaultStyle 25 | { 26 | [self setStyle1]; 27 | } 28 | 29 | - (void)setStyle1 30 | { 31 | self.doBackColor = DO_RGB(232, 229, 222); 32 | self.doButtonColor = DO_RGB(52, 152, 219); 33 | self.doCancelColor = DO_RGB(231, 76, 60); 34 | self.doDestructiveColor = DO_RGB(46, 204, 113); 35 | 36 | self.doTitleTextColor = DO_RGB(95, 74, 50); 37 | self.doButtonTextColor = DO_RGB(255, 255, 255); 38 | self.doCancelTextColor = DO_RGB(255, 255, 255); 39 | self.doDestructiveTextColor = DO_RGB(255, 255, 255); 40 | 41 | self.doDimmedColor = DO_RGBA(0, 0, 0, 0.7); 42 | 43 | self.doTitleFont = [UIFont fontWithName:@"Avenir-Heavy" size:14]; 44 | self.doButtonFont = [UIFont fontWithName:@"Avenir-Medium" size:14]; 45 | self.doCancelFont = [UIFont fontWithName:@"Avenir-Medium" size:14]; 46 | 47 | self.doTitleInset = UIEdgeInsetsMake(10, 20, 10, 20); 48 | self.doButtonInset = UIEdgeInsetsMake(5, 20, 5, 20); 49 | 50 | self.doButtonHeight = 40.0f; 51 | } 52 | 53 | - (void)setStyle2 54 | { 55 | self.doBackColor = DO_RGBA(255, 255, 255, 0); 56 | self.doButtonColor = DO_RGB(113, 208, 243); 57 | self.doCancelColor = DO_RGB(73, 168, 203); 58 | self.doDestructiveColor = DO_RGB(235, 15, 93); 59 | 60 | self.doTitleTextColor = DO_RGB(209, 247, 247); 61 | self.doButtonTextColor = DO_RGB(255, 255, 255); 62 | self.doCancelTextColor = DO_RGB(255, 255, 255); 63 | self.doDestructiveTextColor = DO_RGB(255, 255, 255); 64 | } 65 | 66 | - (void)setStyle3 67 | { 68 | self.doBackColor = [UIColor clearColor]; 69 | self.doButtonColor = [UIColor whiteColor]; 70 | self.doCancelColor = [UIColor whiteColor]; 71 | self.doDestructiveColor = [UIColor redColor]; 72 | 73 | self.doTitleTextColor = [UIColor grayColor]; 74 | self.doButtonTextColor = [UIColor purpleColor]; 75 | self.doCancelTextColor = [UIColor orangeColor]; 76 | self.doDestructiveTextColor = [UIColor whiteColor]; 77 | 78 | self.doTitleFont = [UIFont systemFontOfSize:18]; 79 | self.doButtonFont = [UIFont systemFontOfSize:18]; 80 | self.doCancelFont = [UIFont systemFontOfSize:18]; 81 | self.doButtonHeight = 44.0f; 82 | } 83 | 84 | @end 85 | -------------------------------------------------------------------------------- /TestActionSheet/DoActionSheet/DoActionSheet.h: -------------------------------------------------------------------------------- 1 | // 2 | // DoActionSheet.h 3 | // TestActionSheet 4 | // 5 | // Created by Donobono on 2014. 01. 01.. 6 | // 7 | 8 | #import 9 | #import 10 | 11 | #define DO_RGB(r, g, b) [UIColor colorWithRed:r/255.0 green:g/255.0 blue:b/255.0 alpha:1] 12 | #define DO_RGBA(r, g, b, a) [UIColor colorWithRed:r/255.0 green:g/255.0 blue:b/255.0 alpha:a] 13 | 14 | /* color set 1 ----------------------------------------------------------------------------- 15 | #define DO_AS_BACK_COLOR DO_RGB(255, 244, 244) 16 | 17 | // button background color 18 | #define DO_AS_BUTTON_COLOR DO_RGB(246, 224, 224) 19 | #define DO_AS_CANCEL_COLOR DO_RGB(226, 204, 204) 20 | #define DO_AS_DESTRUCTIVE_COLOR DO_RGB(242, 156, 159) 21 | 22 | // button text color 23 | #define DO_AS_TITLE_TEXT_COLOR DO_RGB(144, 110, 59) 24 | #define DO_AS_BUTTON_TEXT_COLOR DO_RGB(255, 255, 255) 25 | #define DO_AS_CANCEL_TEXT_COLOR DO_RGB(255, 255, 255) 26 | #define DO_AS_DESTRUCTIVE_TEXT_COLOR DO_RGB(255, 255, 255) 27 | */ 28 | 29 | //#define DO_AS_TITLE_BOX DO_RGB(113, 208, 243) 30 | //#define DO_AS_NORMAL_BOX DO_RGB(57, 185, 238) 31 | //#define DO_AS_BUTTON_BOX DO_RGB(113, 208, 243) 32 | //#define DO_AS_DESTRUCTIVE_BOX DO_RGB(235, 15, 93) 33 | //#define DO_AS_TEXT_COLOR DO_RGB(255, 255, 255) 34 | //#define DO_AS_DESTRUCTIVE_TEXT_COLOR DO_RGB(255, 255, 255) 35 | //#define DO_AS_DIMMED_COLOR DO_RGBA(0, 0, 0, 0.7) 36 | 37 | /* color set 2 ----------------------------------------------------------------------------- 38 | #define DO_AS_BACK_COLOR DO_RGBA(255, 255, 255, 0) 39 | 40 | // button background color 41 | #define DO_AS_BUTTON_COLOR DO_RGB(113, 208, 243) 42 | #define DO_AS_CANCEL_COLOR DO_RGB(73, 168, 203) 43 | #define DO_AS_DESTRUCTIVE_COLOR DO_RGB(235, 15, 93) 44 | 45 | // button text color 46 | #define DO_AS_TITLE_TEXT_COLOR DO_RGB(209, 247, 247) 47 | #define DO_AS_BUTTON_TEXT_COLOR DO_RGB(255, 255, 255) 48 | #define DO_AS_CANCEL_TEXT_COLOR DO_RGB(255, 255, 255) 49 | #define DO_AS_DESTRUCTIVE_TEXT_COLOR DO_RGB(255, 255, 255) 50 | */ 51 | 52 | // color set 3 ----------------------------------------------------------------------------- 53 | #define DO_AS_BACK_COLOR DO_RGB(232, 229, 222) 54 | 55 | // button background color 56 | #define DO_AS_BUTTON_COLOR DO_RGB(158, 132, 103) 57 | #define DO_AS_CANCEL_COLOR DO_RGB(240, 185, 103) 58 | #define DO_AS_DESTRUCTIVE_COLOR DO_RGB(124, 192, 134) 59 | 60 | // button text color 61 | #define DO_AS_TITLE_TEXT_COLOR DO_RGB(95, 74, 50) 62 | #define DO_AS_BUTTON_TEXT_COLOR DO_RGB(255, 255, 255) 63 | #define DO_AS_CANCEL_TEXT_COLOR DO_RGB(255, 255, 255) 64 | #define DO_AS_DESTRUCTIVE_TEXT_COLOR DO_RGB(255, 255, 255) 65 | 66 | 67 | 68 | #define DO_AS_DIMMED_COLOR DO_RGBA(0, 0, 0, 0.7) 69 | 70 | #define DO_AS_TITLE_FONT [UIFont fontWithName:@"Avenir-Heavy" size:14] 71 | #define DO_AS_BUTTON_FONT [UIFont fontWithName:@"Avenir-Medium" size:14] 72 | 73 | #define DO_AS_TITLE_INSET UIEdgeInsetsMake(10, 20, 10, 20) 74 | #define DO_AS_BUTTON_INSET UIEdgeInsetsMake(5, 20, 5, 20) 75 | 76 | #define DO_AS_BUTTON_HEIGHT 40 77 | #define DO_AS_SCROLL_HEIGHT 300 78 | 79 | #define DO_AS_CANCEL_TAG -100 80 | 81 | typedef NS_ENUM(int, DoAlertViewTransitionStyle) { 82 | DoASTransitionStyleNormal = 0, 83 | DoASTransitionStyleFade, 84 | DoASTransitionStylePop, 85 | }; 86 | 87 | typedef NS_ENUM(int, DoAlertViewContentType) { 88 | DoASContentNone = 0, 89 | DoASContentImage, 90 | DoASContentMap, 91 | }; 92 | 93 | @class DoActionSheet; 94 | typedef void(^DoActionSheetHandler)(int nResult); 95 | 96 | @interface DoActionSheet : UIView 97 | { 98 | @private 99 | NSString *_strTitle; 100 | NSString *_strCancel; 101 | 102 | UIWindow *_actionWindow; 103 | UIView *_vActionSheet; 104 | 105 | DoActionSheetHandler _result; 106 | 107 | CGRect _rectActionSheet; 108 | } 109 | 110 | @property (readwrite) int nAnimationType; 111 | @property (readwrite) int nContentMode; 112 | @property (readwrite) int nDestructiveIndex; 113 | 114 | @property (readwrite) double dRound; 115 | @property (readwrite) double dButtonRound; 116 | 117 | @property (readwrite) BOOL bDestructive; 118 | @property (readonly) int nTag; 119 | 120 | @property (strong, nonatomic) NSArray *aButtons; 121 | 122 | // add content 123 | // for UIImageView 124 | @property (nonatomic, strong) UIImage *iImage; 125 | // for Map view 126 | @property (nonatomic, strong) NSDictionary *dLocation; // latitude, longitude 127 | 128 | // button background color 129 | @property (strong, nonatomic) UIColor *doBackColor; 130 | @property (strong, nonatomic) UIColor *doButtonColor; 131 | @property (strong, nonatomic) UIColor *doCancelColor; 132 | @property (strong, nonatomic) UIColor *doDestructiveColor; 133 | 134 | // button text color 135 | @property (strong, nonatomic) UIColor *doTitleTextColor; 136 | @property (strong, nonatomic) UIColor *doButtonTextColor; 137 | @property (strong, nonatomic) UIColor *doCancelTextColor; 138 | @property (strong, nonatomic) UIColor *doDestructiveTextColor; 139 | 140 | // dimmed color 141 | @property (strong, nonatomic) UIColor *doDimmedColor; 142 | 143 | // button font 144 | @property (strong, nonatomic) UIFont *doTitleFont; 145 | @property (strong, nonatomic) UIFont *doButtonFont; 146 | @property (strong, nonatomic) UIFont *doCancelFont; 147 | 148 | // insets 149 | @property (readwrite) UIEdgeInsets doTitleInset; 150 | @property (readwrite) UIEdgeInsets doButtonInset; 151 | 152 | // button height 153 | @property (readwrite) CGFloat doButtonHeight; 154 | 155 | 156 | // with cancel button and other buttons 157 | - (void)showC:(NSString *)strTitle 158 | cancel:(NSString *)strCancel 159 | buttons:(NSArray *)aButtons 160 | result:(DoActionSheetHandler)result; 161 | 162 | // with cancel button and other buttons, without title 163 | - (void)showC:(NSString *)strCancel 164 | buttons:(NSArray *)aButtons 165 | result:(DoActionSheetHandler)result; 166 | 167 | // with only buttons 168 | - (void)show:(NSString *)strTitle 169 | buttons:(NSArray *)aButtons 170 | result:(DoActionSheetHandler)result; 171 | 172 | // with only buttons, without title 173 | - (void)show:(NSArray *)aButtons 174 | result:(DoActionSheetHandler)result; 175 | 176 | 177 | @end 178 | -------------------------------------------------------------------------------- /TestActionSheet/DoActionSheet/DoActionSheet.m: -------------------------------------------------------------------------------- 1 | // 2 | // DoActionSheet.m 3 | // TestActionSheet 4 | // 5 | // Created by Donobono on 2014. 01. 01.. 6 | // 7 | 8 | #import "DoActionSheet.h" 9 | #import "UIImage+ResizeMagick.h" // Created by Vlad Andersen on 1/5/13. 10 | 11 | #pragma mark - DoAlertViewController 12 | 13 | @interface DoActionSheetController : UIViewController 14 | 15 | @property (nonatomic, strong) DoActionSheet *actionSheet; 16 | 17 | @end 18 | 19 | @implementation DoActionSheetController 20 | 21 | #pragma mark - View life cycle 22 | 23 | - (void)viewDidLoad 24 | { 25 | [super viewDidLoad]; 26 | self.view = _actionSheet; 27 | } 28 | 29 | - (UIStatusBarStyle)preferredStatusBarStyle 30 | { 31 | return [UIApplication sharedApplication].statusBarStyle; 32 | } 33 | 34 | - (BOOL)prefersStatusBarHidden 35 | { 36 | return [UIApplication sharedApplication].statusBarHidden; 37 | } 38 | 39 | @end 40 | 41 | @implementation DoActionSheet 42 | 43 | - (id)initWithFrame:(CGRect)frame 44 | { 45 | self = [super initWithFrame:frame]; 46 | if (self) { 47 | [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(receivedRotate:) name:UIDeviceOrientationDidChangeNotification object:nil]; 48 | 49 | _nDestructiveIndex = -1; 50 | } 51 | return self; 52 | } 53 | 54 | // with cancel button and other buttons 55 | - (void)showC:(NSString *)strTitle 56 | cancel:(NSString *)strCancel 57 | buttons:(NSArray *)aButtons 58 | result:(DoActionSheetHandler)result 59 | { 60 | _strTitle = strTitle; 61 | _strCancel = strCancel; 62 | _aButtons = aButtons; 63 | _result = result; 64 | 65 | [self showActionSheet]; 66 | } 67 | 68 | // with cancel button and other buttons, without title 69 | - (void)showC:(NSString *)strCancel 70 | buttons:(NSArray *)aButtons 71 | result:(DoActionSheetHandler)result 72 | { 73 | _strTitle = nil; 74 | _strCancel = strCancel; 75 | _aButtons = aButtons; 76 | _result = result; 77 | 78 | [self showActionSheet]; 79 | } 80 | 81 | // with only buttons 82 | - (void)show:(NSString *)strTitle 83 | buttons:(NSArray *)aButtons 84 | result:(DoActionSheetHandler)result 85 | { 86 | _strTitle = strTitle; 87 | _strCancel = nil; 88 | _aButtons = aButtons; 89 | _result = result; 90 | 91 | [self showActionSheet]; 92 | } 93 | 94 | // with only buttons, without title 95 | - (void)show:(NSArray *)aButtons 96 | result:(DoActionSheetHandler)result 97 | { 98 | _strTitle = nil; 99 | _strCancel = nil; 100 | _aButtons = aButtons; 101 | _result = result; 102 | 103 | [self showActionSheet]; 104 | } 105 | 106 | - (double)getTextHeight:(UILabel *)lbText 107 | { 108 | double dHeight = 0.0; 109 | 110 | if ([[[UIDevice currentDevice] systemVersion] doubleValue] >= 7.0) 111 | { 112 | NSDictionary *attributes = @{NSFontAttributeName:lbText.font}; 113 | CGRect rect = [lbText.text boundingRectWithSize:CGSizeMake(lbText.frame.size.width, MAXFLOAT) 114 | options:NSStringDrawingUsesLineFragmentOrigin 115 | attributes:attributes 116 | context:nil]; 117 | 118 | dHeight = ceil(rect.size.height); 119 | } 120 | else 121 | { 122 | CGSize size = [lbText.text sizeWithFont:lbText.font 123 | constrainedToSize:CGSizeMake(lbText.frame.size.width, MAXFLOAT) 124 | lineBreakMode:NSLineBreakByWordWrapping]; 125 | 126 | dHeight = ceil(size.height); 127 | } 128 | 129 | return dHeight; 130 | } 131 | 132 | - (void)setLabelAttributes:(UILabel *)lb 133 | { 134 | lb.backgroundColor = [UIColor clearColor]; 135 | lb.textAlignment = NSTextAlignmentCenter; 136 | lb.numberOfLines = 0; 137 | 138 | lb.font = (self.doTitleFont == nil) ? DO_AS_TITLE_FONT : self.doTitleFont; 139 | lb.textColor = (self.doTitleTextColor == nil) ? DO_AS_TITLE_TEXT_COLOR : self.doTitleTextColor; 140 | } 141 | 142 | - (void)setButtonAttributes:(UIButton *)bt cancel:(BOOL)bCancel 143 | { 144 | bt.autoresizingMask = UIViewAutoresizingFlexibleWidth; 145 | 146 | if (bCancel) 147 | { 148 | bt.backgroundColor = (self.doCancelColor == nil) ? DO_AS_CANCEL_COLOR : self.doCancelColor; 149 | bt.titleLabel.font = (self.doCancelFont == nil) ? DO_AS_TITLE_FONT : self.doCancelFont; 150 | [bt setTitleColor:(self.doCancelTextColor == nil) ? DO_AS_CANCEL_TEXT_COLOR : self.doCancelTextColor forState:UIControlStateNormal]; 151 | } 152 | else 153 | { 154 | bt.backgroundColor = (self.doButtonColor == nil) ? DO_AS_BUTTON_COLOR : self.doButtonColor; 155 | bt.titleLabel.font = (self.doButtonFont == nil) ? DO_AS_BUTTON_FONT : self.doButtonFont; 156 | [bt setTitleColor:(self.doButtonTextColor == nil) ? DO_AS_BUTTON_TEXT_COLOR : self.doButtonTextColor forState:UIControlStateNormal]; 157 | } 158 | 159 | if (_dButtonRound > 0) 160 | { 161 | CALayer *layer = [bt layer]; 162 | [layer setMasksToBounds:YES]; 163 | [layer setCornerRadius:_dButtonRound]; 164 | } 165 | 166 | [bt addTarget:self action:@selector(buttonTarget:) forControlEvents:UIControlEventTouchUpInside]; 167 | } 168 | 169 | - (void)showActionSheet 170 | { 171 | double dHeight = 0; 172 | self.backgroundColor = (self.doDimmedColor == nil) ? DO_AS_DIMMED_COLOR : self.doDimmedColor; 173 | 174 | // make back view ----------------------------------------------------------------------------------------------- 175 | _vActionSheet = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 320, 0)]; 176 | _vActionSheet.backgroundColor = (self.doBackColor == nil) ? DO_AS_BACK_COLOR : self.doBackColor; 177 | [self addSubview:_vActionSheet]; 178 | 179 | // Title -------------------------------------------------------------------------------------------------------- 180 | if (_strTitle != nil && _strTitle.length > 0) 181 | { 182 | if (self.doTitleInset.top == 0 && self.doTitleInset.left == 0 && self.doTitleInset.bottom == 0 && self.doTitleInset.right == 0) { 183 | self.doTitleInset = DO_AS_TITLE_INSET; 184 | } 185 | 186 | UILabel *lbTitle = [[UILabel alloc] initWithFrame:CGRectMake(self.doTitleInset.left, self.doTitleInset.top, 187 | _vActionSheet.frame.size.width - (self.doTitleInset.left + self.doTitleInset.right) , 0)]; 188 | lbTitle.text = _strTitle; 189 | [self setLabelAttributes:lbTitle]; 190 | lbTitle.frame = CGRectMake(self.doTitleInset.left, self.doTitleInset.top, lbTitle.frame.size.width, [self getTextHeight:lbTitle]); 191 | lbTitle.autoresizingMask = UIViewAutoresizingFlexibleWidth; 192 | [_vActionSheet addSubview:lbTitle]; 193 | 194 | dHeight = lbTitle.frame.size.height + self.doTitleInset.bottom; 195 | 196 | // underline 197 | UIView *vLine = [[UIView alloc] initWithFrame:CGRectMake(lbTitle.frame.origin.x, lbTitle.frame.origin.y + lbTitle.frame.size.height - 3, lbTitle.frame.size.width, 0.5)]; 198 | vLine.backgroundColor = (self.doTitleTextColor == nil) ? DO_AS_TITLE_TEXT_COLOR : self.doTitleTextColor; 199 | vLine.alpha = 0.2; 200 | vLine.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleRightMargin; 201 | [_vActionSheet addSubview:vLine]; 202 | } 203 | else 204 | dHeight += self.doTitleInset.bottom; 205 | 206 | if (self.doButtonInset.top == 0 && self.doButtonInset.left == 0 && self.doButtonInset.bottom == 0 && self.doButtonInset.right == 0) { 207 | self.doButtonInset = DO_AS_BUTTON_INSET; 208 | } 209 | // add scrollview for many buttons and content 210 | UIScrollView *sc = [[UIScrollView alloc] initWithFrame:CGRectMake(0, dHeight + self.doButtonInset.top, 320, 370)]; 211 | sc.backgroundColor = [UIColor clearColor]; 212 | [_vActionSheet addSubview:sc]; 213 | sc.autoresizingMask = UIViewAutoresizingFlexibleWidth; 214 | 215 | double dYContent = 0; 216 | 217 | dYContent += [self addContent:sc]; 218 | if (dYContent > 0) 219 | dYContent += self.doButtonInset.bottom + self.doButtonInset.top; 220 | 221 | // add buttons 222 | int nTagIndex = 0; 223 | for (NSString *str in _aButtons) 224 | { 225 | UIButton *bt = [UIButton buttonWithType:UIButtonTypeCustom]; 226 | bt.tag = nTagIndex; 227 | [bt setTitle:str forState:UIControlStateNormal]; 228 | 229 | [self setButtonAttributes:bt cancel:NO]; 230 | bt.frame = CGRectMake(self.doButtonInset.left, dYContent, 231 | _vActionSheet.frame.size.width - (self.doButtonInset.left + self.doButtonInset.right), (self.doButtonHeight > 0) ? self.doButtonHeight : DO_AS_BUTTON_HEIGHT); 232 | 233 | dYContent += ((self.doButtonHeight > 0) ? self.doButtonHeight : DO_AS_BUTTON_HEIGHT) + self.doButtonInset.bottom; 234 | 235 | [sc addSubview:bt]; 236 | 237 | if (nTagIndex == _nDestructiveIndex) 238 | { 239 | bt.backgroundColor = (self.doDestructiveColor == nil) ? DO_AS_DESTRUCTIVE_COLOR : self.doDestructiveColor; 240 | [bt setTitleColor:(self.doDestructiveTextColor == nil) ? DO_AS_DESTRUCTIVE_TEXT_COLOR : self.doDestructiveTextColor forState:UIControlStateNormal]; 241 | } 242 | 243 | nTagIndex += 1; 244 | } 245 | 246 | sc.contentSize = CGSizeMake(sc.frame.size.width, dYContent); 247 | dHeight += self.doButtonInset.bottom + MIN(dYContent, sc.frame.size.height); 248 | 249 | // add Cancel button 250 | if (_strCancel != nil && _strCancel.length > 0) 251 | { 252 | UIButton *bt = [UIButton buttonWithType:UIButtonTypeCustom]; 253 | bt.tag = DO_AS_CANCEL_TAG; 254 | [bt setTitle:_strCancel forState:UIControlStateNormal]; 255 | 256 | [self setButtonAttributes:bt cancel:YES]; 257 | bt.frame = CGRectMake(self.doButtonInset.left, dHeight + self.doButtonInset.top + self.doButtonInset.bottom, 258 | _vActionSheet.frame.size.width - (self.doButtonInset.left + self.doButtonInset.right), (self.doButtonHeight > 0) ? self.doButtonHeight : DO_AS_BUTTON_HEIGHT); 259 | 260 | dHeight += ((self.doButtonHeight > 0) ? self.doButtonHeight : DO_AS_BUTTON_HEIGHT) + (self.doButtonInset.top + self.doButtonInset.bottom) * 2; 261 | 262 | [_vActionSheet addSubview:bt]; 263 | } 264 | else 265 | dHeight += self.doButtonInset.bottom; 266 | 267 | _vActionSheet.frame = CGRectMake(0, 0, _vActionSheet.frame.size.width, dHeight + 10); 268 | 269 | DoActionSheetController *viewController = [[DoActionSheetController alloc] initWithNibName:nil bundle:nil]; 270 | viewController.actionSheet = self; 271 | 272 | if (!_actionWindow) 273 | { 274 | UIWindow *window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds]; 275 | window.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight; 276 | window.opaque = NO; 277 | window.windowLevel = UIWindowLevelAlert; 278 | window.rootViewController = viewController; 279 | _actionWindow = window; 280 | 281 | self.frame = window.frame; 282 | _vActionSheet.center = window.center; 283 | } 284 | [_actionWindow makeKeyAndVisible]; 285 | 286 | if (_dRound > 0) 287 | { 288 | CALayer *layer = [_vActionSheet layer]; 289 | [layer setMasksToBounds:YES]; 290 | [layer setCornerRadius:_dRound]; 291 | } 292 | 293 | [self showAnimation]; 294 | } 295 | 296 | - (void)buttonTarget:(id)sender 297 | { 298 | _result([sender tag]); 299 | [self hideAnimation]; 300 | } 301 | 302 | - (double)addContent:(UIScrollView *)sc 303 | { 304 | double dContentOffset = 0; 305 | 306 | if (self.doButtonInset.top == 0 && self.doButtonInset.left == 0 && self.doButtonInset.bottom == 0 && self.doButtonInset.right == 0) { 307 | self.doButtonInset = DO_AS_BUTTON_INSET; 308 | } 309 | switch (_nContentMode) { 310 | case DoASContentImage: 311 | { 312 | UIImageView *iv = nil; 313 | if (_iImage != nil) 314 | { 315 | UIImage *iResized = [_iImage resizedImageWithMaximumSize:CGSizeMake(360, 360)]; 316 | 317 | iv = [[UIImageView alloc] initWithImage:iResized]; 318 | iv.contentMode = UIViewContentModeScaleAspectFit; 319 | iv.frame = CGRectMake(self.doButtonInset.left, self.doButtonInset.top, iResized.size.width / 2, iResized.size.height / 2); 320 | iv.center = CGPointMake(sc.center.x, iv.center.y); 321 | iv.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleRightMargin; 322 | 323 | [sc addSubview:iv]; 324 | dContentOffset = iv.frame.size.height + self.doButtonInset.bottom + self.doButtonInset.bottom; 325 | } 326 | } 327 | break; 328 | 329 | case DoASContentMap: 330 | { 331 | if (_dLocation == nil) 332 | { 333 | dContentOffset = 0; 334 | break; 335 | } 336 | 337 | MKMapView *vMap = [[MKMapView alloc] initWithFrame:CGRectMake(self.doButtonInset.left, self.doButtonInset.top, 338 | 240, 180)]; 339 | vMap.center = CGPointMake(sc.center.x, vMap.center.y); 340 | 341 | vMap.delegate = self; 342 | vMap.centerCoordinate = CLLocationCoordinate2DMake([_dLocation[@"latitude"] doubleValue], [_dLocation[@"longitude"] doubleValue]); 343 | vMap.camera.altitude = [_dLocation[@"altitude"] doubleValue]; 344 | vMap.camera.pitch = 70; 345 | vMap.showsBuildings = YES; 346 | vMap.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleRightMargin; 347 | 348 | [sc addSubview:vMap]; 349 | dContentOffset = 180 + self.doButtonInset.bottom; 350 | 351 | MKPointAnnotation *annotation = [[MKPointAnnotation alloc] init]; 352 | annotation.coordinate = vMap.centerCoordinate; 353 | annotation.title = @"Here~"; 354 | [vMap addAnnotation:annotation]; 355 | } 356 | break; 357 | 358 | default: 359 | break; 360 | } 361 | 362 | return dContentOffset; 363 | } 364 | 365 | - (void)hideActionSheet 366 | { 367 | [self removeFromSuperview]; 368 | [_actionWindow removeFromSuperview]; 369 | _actionWindow = nil; 370 | } 371 | 372 | - (void)showAnimation 373 | { 374 | self.alpha = 0.0; 375 | 376 | switch (_nAnimationType) { 377 | case DoASTransitionStyleNormal: 378 | case DoASTransitionStylePop: 379 | _vActionSheet.frame = CGRectMake(0, self.bounds.size.height, 380 | self.bounds.size.width, _vActionSheet.frame.size.height + _dRound + 5); 381 | break; 382 | 383 | case DoASTransitionStyleFade: 384 | _vActionSheet.alpha = 0.0; 385 | _vActionSheet.frame = CGRectMake(0, self.bounds.size.height - _vActionSheet.frame.size.height + 5, 386 | self.bounds.size.width, _vActionSheet.frame.size.height + _dRound + 5); 387 | break; 388 | 389 | default: 390 | break; 391 | } 392 | 393 | [UIView animateWithDuration:0.2 animations:^(void) { 394 | self.alpha = 1.0; 395 | 396 | [UIView setAnimationDelay:0.1]; 397 | 398 | switch (_nAnimationType) { 399 | case DoASTransitionStyleNormal: 400 | _vActionSheet.frame = CGRectMake(0, self.bounds.size.height - _vActionSheet.frame.size.height + 15, 401 | self.bounds.size.width, _vActionSheet.frame.size.height); 402 | 403 | break; 404 | 405 | case DoASTransitionStyleFade: 406 | _vActionSheet.alpha = 1.0; 407 | break; 408 | 409 | case DoASTransitionStylePop: 410 | _vActionSheet.frame = CGRectMake(0, self.bounds.size.height - _vActionSheet.frame.size.height + 10, 411 | self.bounds.size.width, _vActionSheet.frame.size.height); 412 | 413 | break; 414 | 415 | default: 416 | break; 417 | } 418 | } completion:^(BOOL finished) { 419 | 420 | if (_nAnimationType == DoASTransitionStylePop) 421 | { 422 | [UIView animateWithDuration:0.1 animations:^(void) { 423 | 424 | _vActionSheet.frame = CGRectMake(0, self.bounds.size.height - _vActionSheet.frame.size.height + 18, 425 | self.bounds.size.width, _vActionSheet.frame.size.height); 426 | 427 | } completion:^(BOOL finished) { 428 | 429 | [UIView animateWithDuration:0.1 animations:^(void) { 430 | _vActionSheet.frame = CGRectMake(0, self.bounds.size.height - _vActionSheet.frame.size.height + 15, 431 | self.bounds.size.width, _vActionSheet.frame.size.height); 432 | 433 | }]; 434 | }]; 435 | } 436 | }]; 437 | } 438 | 439 | - (void)hideAnimation 440 | { 441 | [[NSNotificationCenter defaultCenter] removeObserver:self name:UIDeviceOrientationDidChangeNotification object:nil]; 442 | 443 | [UIView animateWithDuration:0.2 animations:^(void) { 444 | 445 | switch (_nAnimationType) { 446 | case DoASTransitionStyleNormal: 447 | _vActionSheet.frame = CGRectMake(0, self.bounds.size.height, 448 | self.bounds.size.width, _vActionSheet.frame.size.height); 449 | break; 450 | 451 | case DoASTransitionStyleFade: 452 | _vActionSheet.alpha = 0.0; 453 | break; 454 | 455 | case DoASTransitionStylePop: 456 | _vActionSheet.frame = CGRectMake(0, self.bounds.size.height - _vActionSheet.frame.size.height + 10, 457 | self.bounds.size.width, _vActionSheet.frame.size.height); 458 | 459 | break; 460 | } 461 | 462 | [UIView setAnimationDelay:0.1]; 463 | if (_nAnimationType != DoASTransitionStylePop) 464 | { 465 | _vActionSheet.alpha = 0.0; 466 | self.alpha = 0.0; 467 | } 468 | 469 | } completion:^(BOOL finished) { 470 | 471 | if (_nAnimationType == DoASTransitionStylePop) 472 | { 473 | [UIView animateWithDuration:0.1 animations:^(void) { 474 | 475 | [UIView setAnimationDelay:0.1]; 476 | _vActionSheet.frame = CGRectMake(0, self.bounds.size.height, 477 | self.bounds.size.width, _vActionSheet.frame.size.height); 478 | 479 | } completion:^(BOOL finished) { 480 | 481 | [UIView animateWithDuration:0.1 animations:^(void) { 482 | 483 | [UIView setAnimationDelay:0.1]; 484 | self.alpha = 0.0; 485 | 486 | } completion:^(BOOL finished) { 487 | 488 | [self hideActionSheet]; 489 | 490 | }]; 491 | }]; 492 | } 493 | else 494 | { 495 | [self hideActionSheet]; 496 | } 497 | }]; 498 | } 499 | 500 | -(void)receivedRotate: (NSNotification *)notification 501 | { 502 | dispatch_async(dispatch_get_main_queue(), ^(void) { 503 | 504 | [UIView animateWithDuration:0.2 animations:^(void) { 505 | _vActionSheet.frame = CGRectMake(0, self.bounds.size.height - _vActionSheet.frame.size.height + 15, 506 | self.bounds.size.width, _vActionSheet.frame.size.height); 507 | }]; 508 | }); 509 | } 510 | 511 | - (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event 512 | { 513 | CGPoint pt = [[touches anyObject] locationInView:self]; 514 | if (CGRectContainsPoint(_vActionSheet.frame, pt)) 515 | return; 516 | 517 | _result(DO_AS_CANCEL_TAG); 518 | [self hideAnimation]; 519 | } 520 | 521 | @end 522 | -------------------------------------------------------------------------------- /TestActionSheet/Images.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" : "40x40", 11 | "scale" : "2x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "60x60", 16 | "scale" : "2x" 17 | } 18 | ], 19 | "info" : { 20 | "version" : 1, 21 | "author" : "xcode" 22 | } 23 | } -------------------------------------------------------------------------------- /TestActionSheet/Images.xcassets/LaunchImage.launchimage/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "orientation" : "portrait", 5 | "idiom" : "iphone", 6 | "extent" : "full-screen", 7 | "minimum-system-version" : "7.0", 8 | "scale" : "2x" 9 | }, 10 | { 11 | "orientation" : "portrait", 12 | "idiom" : "iphone", 13 | "subtype" : "retina4", 14 | "extent" : "full-screen", 15 | "minimum-system-version" : "7.0", 16 | "scale" : "2x" 17 | } 18 | ], 19 | "info" : { 20 | "version" : 1, 21 | "author" : "xcode" 22 | } 23 | } -------------------------------------------------------------------------------- /TestActionSheet/TestActionSheet-Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleDisplayName 8 | ${PRODUCT_NAME} 9 | CFBundleExecutable 10 | ${EXECUTABLE_NAME} 11 | CFBundleIdentifier 12 | com.lovelyhoy.${PRODUCT_NAME:rfc1034identifier} 13 | CFBundleInfoDictionaryVersion 14 | 6.0 15 | CFBundleName 16 | ${PRODUCT_NAME} 17 | CFBundlePackageType 18 | APPL 19 | CFBundleShortVersionString 20 | 1.0 21 | CFBundleSignature 22 | ???? 23 | CFBundleVersion 24 | 1.0 25 | LSRequiresIPhoneOS 26 | 27 | UIMainStoryboardFile 28 | Main 29 | UIRequiredDeviceCapabilities 30 | 31 | armv7 32 | 33 | UISupportedInterfaceOrientations 34 | 35 | UIInterfaceOrientationPortrait 36 | UIInterfaceOrientationLandscapeLeft 37 | UIInterfaceOrientationLandscapeRight 38 | 39 | 40 | 41 | -------------------------------------------------------------------------------- /TestActionSheet/TestActionSheet-Prefix.pch: -------------------------------------------------------------------------------- 1 | // 2 | // Prefix header 3 | // 4 | // The contents of this file are implicitly included at the beginning of every source file. 5 | // 6 | 7 | #import 8 | 9 | #ifndef __IPHONE_5_0 10 | #warning "This project uses features only available in iOS SDK 5.0 and later." 11 | #endif 12 | 13 | #ifdef __OBJC__ 14 | #import 15 | #import 16 | #endif 17 | -------------------------------------------------------------------------------- /TestActionSheet/ViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.h 3 | // TestActionSheet 4 | // 5 | // Created by Dono Air on 2014. 1. 1.. 6 | // Copyright (c) 2014년 Dono Air. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface ViewController : UIViewController 12 | 13 | @property (weak, nonatomic) IBOutlet UISegmentedControl *sgSelect; 14 | @property (weak, nonatomic) IBOutlet UISegmentedControl *sgType; 15 | @property (weak, nonatomic) IBOutlet UISegmentedControl *sgSelectImage; 16 | @property (weak, nonatomic) IBOutlet UISegmentedControl *sgStyle; 17 | 18 | 19 | @property (weak, nonatomic) IBOutlet UILabel *lbMode; 20 | @property (weak, nonatomic) IBOutlet UILabel *lbType; 21 | @property (weak, nonatomic) IBOutlet UILabel *lbStyle; 22 | 23 | 24 | - (IBAction)onShowAlert:(id)sender; 25 | 26 | - (IBAction)onSelect:(id)sender; 27 | - (IBAction)onSelectAnimationType:(id)sender; 28 | - (IBAction)onSelectStyle:(id)sender; 29 | 30 | 31 | @end 32 | -------------------------------------------------------------------------------- /TestActionSheet/ViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.m 3 | // TestActionSheet 4 | // 5 | // Created by Dono Air on 2014. 1. 1.. 6 | // Copyright (c) 2014년 Dono Air. All rights reserved. 7 | // 8 | 9 | #import "ViewController.h" 10 | #import "DoActionSheet+Demo.h" 11 | 12 | @implementation ViewController 13 | 14 | - (void)viewDidLoad 15 | { 16 | [super viewDidLoad]; 17 | 18 | _sgSelect.selectedSegmentIndex = 0; 19 | _sgType.selectedSegmentIndex = 0; 20 | _sgStyle.selectedSegmentIndex = 0; 21 | 22 | [self onSelect:nil]; 23 | [self onSelectAnimationType:nil]; 24 | [self onSelectStyle:nil]; 25 | } 26 | 27 | - (IBAction)onShowAlert:(id)sender 28 | { 29 | DoActionSheet *vActionSheet = [[DoActionSheet alloc] init]; 30 | vActionSheet.nAnimationType = _sgType.selectedSegmentIndex; 31 | 32 | if (_sgStyle.selectedSegmentIndex == 0) 33 | [vActionSheet setStyle1]; 34 | else if (_sgStyle.selectedSegmentIndex == 1) 35 | [vActionSheet setStyle2]; 36 | else if (_sgStyle.selectedSegmentIndex == 2) 37 | [vActionSheet setStyle3]; 38 | 39 | 40 | if (_sgSelect.selectedSegmentIndex != 1) 41 | vActionSheet.dRound = 5; 42 | 43 | vActionSheet.dButtonRound = 2; 44 | 45 | if (_sgSelectImage.selectedSegmentIndex == 1) 46 | { 47 | vActionSheet.iImage = [UIImage imageNamed:@"pic1.jpg"]; 48 | vActionSheet.nContentMode = DoASContentImage; 49 | } 50 | else if (_sgSelectImage.selectedSegmentIndex == 2) 51 | { 52 | vActionSheet.iImage = [UIImage imageNamed:@"pic2.jpg"]; 53 | vActionSheet.nContentMode = DoASContentImage; 54 | } 55 | else if (_sgSelectImage.selectedSegmentIndex == 3) 56 | { 57 | vActionSheet.nContentMode = DoASContentMap; 58 | vActionSheet.dLocation = @{@"latitude" : @(37.78275123), @"longitude" : @(-122.40416442), @"altitude" : @200}; 59 | } 60 | 61 | switch (_sgSelect.selectedSegmentIndex) { 62 | case 0: 63 | vActionSheet.nDestructiveIndex = 2; 64 | 65 | [vActionSheet showC:@"What do you want for this photo? " 66 | cancel:@"Cancel" 67 | buttons:@[@"Post to facebook", @"Post to Instagram", @"Delete this photo"] 68 | result:^(int nResult) { 69 | 70 | NSLog(@"---------------> result : %d", nResult); 71 | 72 | }]; 73 | break; 74 | 75 | case 1: 76 | [vActionSheet showC:@"What do you want for this photo?" 77 | cancel:@"Cancel" 78 | buttons:@[@"Post to facebook", @"Post to twitter", @"Post to Instagram", @"Send a mail", @"Save to camera roll"] 79 | result:^(int nResult) { 80 | 81 | NSLog(@"---------------> result : %d", nResult); 82 | 83 | }]; 84 | break; 85 | 86 | case 2: 87 | [vActionSheet showC:@"Cancel" 88 | buttons:@[@"Open with Safari", @"Copy the link"] 89 | result:^(int nResult) { 90 | 91 | NSLog(@"---------------> result : %d", nResult); 92 | 93 | }]; 94 | break; 95 | 96 | case 3: 97 | [vActionSheet show:@"What do you want?" 98 | buttons:@[@"Open with Safari", @"Copy the link"] 99 | result:^(int nResult) { 100 | 101 | NSLog(@"---------------> result : %d", nResult); 102 | 103 | }]; 104 | break; 105 | 106 | case 4: 107 | [vActionSheet show:@[@"Open with Safari", @"Copy the link"] 108 | result:^(int nResult) { 109 | 110 | NSLog(@"---------------> result : %d", nResult); 111 | 112 | }]; 113 | break; 114 | 115 | default: 116 | break; 117 | } 118 | } 119 | 120 | - (IBAction)onSelect:(id)sender 121 | { 122 | switch (_sgSelect.selectedSegmentIndex) { 123 | case 0: 124 | _lbMode.text = @"With title, destructive button, cancel, others"; 125 | break; 126 | case 1: 127 | _lbMode.text = @"With title, cancel, others"; 128 | break; 129 | case 2: 130 | _lbMode.text = @"Cancel, others"; 131 | break; 132 | case 3: 133 | _lbMode.text = @"With title, others"; 134 | break; 135 | case 4: 136 | _lbMode.text = @"Only normal buttons"; 137 | break; 138 | 139 | default: 140 | break; 141 | } 142 | } 143 | 144 | - (IBAction)onSelectAnimationType:(id)sender 145 | { 146 | switch (_sgType.selectedSegmentIndex) { 147 | case DoASTransitionStyleNormal: 148 | _lbType.text = @"DoTransitionStyleNormal"; 149 | break; 150 | case DoASTransitionStyleFade: 151 | _lbType.text = @"DoTransitionStyleFade"; 152 | break; 153 | case DoASTransitionStylePop: 154 | _lbType.text = @"DoTransitionStylePop"; 155 | break; 156 | 157 | default: 158 | break; 159 | } 160 | } 161 | 162 | - (IBAction)onSelectStyle:(id)sender 163 | { 164 | switch (_sgStyle.selectedSegmentIndex) { 165 | case 0: 166 | _lbStyle.text = @"Style 1"; 167 | break; 168 | case 1: 169 | _lbStyle.text = @"Style 2"; 170 | break; 171 | case 2: 172 | _lbStyle.text = @"Style 3"; 173 | break; 174 | 175 | default: 176 | break; 177 | } 178 | } 179 | 180 | - (void)didReceiveMemoryWarning 181 | { 182 | [super didReceiveMemoryWarning]; 183 | // Dispose of any resources that can be recreated. 184 | } 185 | 186 | @end 187 | -------------------------------------------------------------------------------- /TestActionSheet/en.lproj/InfoPlist.strings: -------------------------------------------------------------------------------- 1 | /* Localized versions of Info.plist keys */ 2 | 3 | -------------------------------------------------------------------------------- /TestActionSheet/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // TestActionSheet 4 | // 5 | // Created by Dono Air on 2014. 1. 1.. 6 | // Copyright (c) 2014년 Dono Air. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | #import "AppDelegate.h" 12 | 13 | int main(int argc, char * argv[]) 14 | { 15 | @autoreleasepool { 16 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /TestActionSheetTests/TestActionSheetTests-Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | ${EXECUTABLE_NAME} 9 | CFBundleIdentifier 10 | com.lovelyhoy.${PRODUCT_NAME:rfc1034identifier} 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundlePackageType 14 | BNDL 15 | CFBundleShortVersionString 16 | 1.0 17 | CFBundleSignature 18 | ???? 19 | CFBundleVersion 20 | 1 21 | 22 | 23 | -------------------------------------------------------------------------------- /TestActionSheetTests/TestActionSheetTests.m: -------------------------------------------------------------------------------- 1 | // 2 | // TestActionSheetTests.m 3 | // TestActionSheetTests 4 | // 5 | // Created by Dono Air on 2014. 1. 1.. 6 | // Copyright (c) 2014년 Dono Air. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface TestActionSheetTests : XCTestCase 12 | 13 | @end 14 | 15 | @implementation TestActionSheetTests 16 | 17 | - (void)setUp 18 | { 19 | [super setUp]; 20 | // Put setup code here. This method is called before the invocation of each test method in the class. 21 | } 22 | 23 | - (void)tearDown 24 | { 25 | // Put teardown code here. This method is called after the invocation of each test method in the class. 26 | [super tearDown]; 27 | } 28 | 29 | - (void)testExample 30 | { 31 | XCTFail(@"No implementation for \"%s\"", __PRETTY_FUNCTION__); 32 | } 33 | 34 | @end 35 | -------------------------------------------------------------------------------- /TestActionSheetTests/en.lproj/InfoPlist.strings: -------------------------------------------------------------------------------- 1 | /* Localized versions of Info.plist keys */ 2 | 3 | -------------------------------------------------------------------------------- /p1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/donobono/DoActionSheet/f439e8653f484e196489104a4f815f114ff3ea2b/p1.png -------------------------------------------------------------------------------- /p2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/donobono/DoActionSheet/f439e8653f484e196489104a4f815f114ff3ea2b/p2.png -------------------------------------------------------------------------------- /p3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/donobono/DoActionSheet/f439e8653f484e196489104a4f815f114ff3ea2b/p3.png -------------------------------------------------------------------------------- /p4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/donobono/DoActionSheet/f439e8653f484e196489104a4f815f114ff3ea2b/p4.png --------------------------------------------------------------------------------