├── .gitignore ├── LICENSE ├── README.md ├── SLButton.podspec ├── SLButton ├── SLButton.h └── SLButton.m ├── SLButtonSample ├── SLButtonSample.xcodeproj │ ├── project.pbxproj │ └── project.xcworkspace │ │ └── contents.xcworkspacedata └── SLButtonSample │ ├── AppDelegate.h │ ├── AppDelegate.m │ ├── Assets.xcassets │ └── AppIcon.appiconset │ │ └── Contents.json │ ├── Base.lproj │ ├── LaunchScreen.storyboard │ └── Main.storyboard │ ├── Info.plist │ ├── ViewController.h │ ├── ViewController.m │ └── main.m ├── ScreenShot-1.png └── ScreenShot-2.png /.gitignore: -------------------------------------------------------------------------------- 1 | # Xcode 2 | # 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 | *.xccheckout 14 | *.moved-aside 15 | DerivedData 16 | *.hmap 17 | *.ipa 18 | *.xcuserstate 19 | *.DS_Store 20 | 21 | # CocoaPods 22 | # 23 | # We recommend against adding the Pods directory to your .gitignore. However 24 | # you should judge for yourself, the pros and cons are mentioned at: 25 | # http://guides.cocoapods.org/using/using-cocoapods.html#should-i-ignore-the-pods-directory-in-source-control 26 | # 27 | # Pods/ -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015 Ali Pourhadi 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | 23 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Screenshots 2 | 3 | ![Before Loading](https://raw.githubusercontent.com/PersianDevelopers/SLButton/master/ScreenShot-1.png) 4 | ![while Loading](https://raw.githubusercontent.com/PersianDevelopers/SLButton/master/ScreenShot-2.png) 5 | 6 | # SLButton 7 | 8 | Simple Loading Button 9 | Very easy to use 10 | 11 | # Installation with CocoaPods 12 | 13 | ```ruby 14 | platform :ios, "7.0" 15 | pod 'SLButton', '~> 0.0.1' 16 | ``` 17 | 18 | # How to Use 19 | import "SLButton.h" 20 | 21 | Optional Properties : 22 | 23 | + AnimationDuration ( animation duration ) 24 | + DisableWhileLoading ( disable button while loading ) 25 | 26 | # Methods Calling 27 | ```objc 28 | [button_object showloading] // to loading mode 29 | 30 | [button_object hideLoading] // to normal mode 31 | ``` 32 | # Requirements 33 | + iOS >= 7.0 34 | 35 | # Author 36 | Ali Pourhadi, ali.pourhadi@gmail.com 37 | 38 | # License 39 | SLButton is available under the MIT license. See the LICENSE file for more info. 40 | -------------------------------------------------------------------------------- /SLButton.podspec: -------------------------------------------------------------------------------- 1 | Pod::Spec.new do |s| 2 | s.name = 'SLButton' 3 | s.version = '0.0.1' 4 | s.summary = 'Lightweight and simple Loading button for iOS' 5 | s.homepage = "https://github.com/PersianDevelopers/SLButton" 6 | s.license = 'MIT' 7 | s.author = { 8 | 'Ali Pourhadi' => 'Ali.Pourhadi@gmail.com' 9 | } 10 | s.source = { 11 | :git => 'https://github.com/PersianDevelopers/SLButton.git', 12 | :tag => s.version.to_s 13 | } 14 | s.source_files = 'SLButton/*.{h,m}' 15 | s.platform = :ios, '7.0' 16 | s.requires_arc = true 17 | s.frameworks = 'UIKit' 18 | end 19 | -------------------------------------------------------------------------------- /SLButton/SLButton.h: -------------------------------------------------------------------------------- 1 | //The MIT License (MIT) 2 | // 3 | //Copyright (c) 2015 Ali Pourhadi 4 | // 5 | //Permission is hereby granted, free of charge, to any person obtaining a copy 6 | //of this software and associated documentation files (the "Software"), to deal 7 | //in the Software without restriction, including without limitation the rights 8 | //to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | //copies of the Software, and to permit persons to whom the Software is 10 | //furnished to do so, subject to the following conditions: 11 | // 12 | //The above copyright notice and this permission notice shall be included in all 13 | //copies or substantial portions of the Software. 14 | // 15 | //THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | //IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | //FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | //AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | //LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | //OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | //SOFTWARE. 22 | 23 | #import 24 | 25 | @interface SLButton : UIButton 26 | 27 | @property (readonly) BOOL isLoading; 28 | 29 | @property float animationDuration; 30 | @property BOOL disableWhileLoading; 31 | 32 | - (void)showLoading; 33 | - (void)hideLoading; 34 | 35 | @end 36 | -------------------------------------------------------------------------------- /SLButton/SLButton.m: -------------------------------------------------------------------------------- 1 | // 2 | // SLButton.m 3 | // Ali Pourhadi 4 | // 5 | // Created by Ali Pourhadi on 2015-09-28. 6 | // Copyright © 2015 Ali Pourhadi. All rights reserved. 7 | // 8 | 9 | #import "SLButton.h" 10 | 11 | @interface SLButton () 12 | @property (strong,nonatomic) UIActivityIndicatorView *activity; 13 | @property (strong, nonatomic) NSString *currentText; 14 | @property CGRect currentBounds; 15 | @property CGFloat currentCornerRadius; 16 | @end 17 | 18 | @implementation SLButton 19 | 20 | - (void)awakeFromNib { 21 | self.animationDuration = 0.3; 22 | self.disableWhileLoading = YES; 23 | } 24 | 25 | - (void)showLoading { 26 | _isLoading = YES; 27 | [self addActivityIndicator]; 28 | [self setCurrentData]; 29 | [self clearText]; 30 | [self disableButton]; 31 | [self deShapeAnimation]; 32 | [self setNeedsDisplay]; 33 | } 34 | 35 | - (void)addActivityIndicator { 36 | self.activity = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:(UIActivityIndicatorViewStyleGray)]; 37 | [self setFrameForActivity]; 38 | [self.activity setHidden:NO]; 39 | [self.activity startAnimating]; 40 | [self.activity setCenter:self.center]; 41 | [self.superview addSubview:self.activity]; 42 | } 43 | 44 | - (void)setCurrentData { 45 | [self setCurrentText:self.currentTitle]; 46 | [self setCurrentBounds:self.bounds]; 47 | [self setCurrentCornerRadius:self.layer.cornerRadius]; 48 | } 49 | 50 | - (void)clearText { 51 | [self setTitle:@"" forState:UIControlStateNormal]; 52 | } 53 | 54 | - (void)disableButton { 55 | if (self.disableWhileLoading) 56 | [self setEnabled:NO]; 57 | } 58 | 59 | - (void)deShapeAnimation { 60 | CABasicAnimation *sizing = [CABasicAnimation animationWithKeyPath:@"bounds"]; 61 | sizing.duration= (self.animationDuration * 2) / 5.0; 62 | if (self.bounds.size.width > self.bounds.size.height) 63 | sizing.toValue= [NSValue valueWithCGRect:CGRectMake(self.layer.bounds.origin.x, self.layer.bounds.origin.y, self.layer.bounds.size.height, self.layer.bounds.size.height)]; 64 | else 65 | sizing.toValue= [NSValue valueWithCGRect:CGRectMake(self.layer.bounds.origin.x, self.layer.bounds.origin.y, self.layer.bounds.size.width, self.layer.bounds.size.width)]; 66 | sizing.removedOnCompletion = FALSE; 67 | sizing.fillMode = kCAFillModeForwards;; 68 | [self.layer addAnimation:sizing forKey:@"de-scale"]; 69 | 70 | CABasicAnimation *shape = [CABasicAnimation animationWithKeyPath:@"cornerRadius"]; 71 | shape.beginTime = CACurrentMediaTime() + (self.animationDuration * 2) / 5.0; 72 | shape.duration = (self.animationDuration * 3) / 5.0; 73 | shape.toValue= @(self.layer.bounds.size.height / 2.0); 74 | shape.removedOnCompletion = FALSE; 75 | shape.fillMode = kCAFillModeForwards;; 76 | [self.layer addAnimation:shape forKey:@"de-shape"]; 77 | } 78 | 79 | - (void)reShapeAnimation { 80 | CABasicAnimation *shape = [CABasicAnimation animationWithKeyPath:@"cornerRadius"]; 81 | shape.duration = (self.animationDuration * 3) / 5.0; 82 | shape.toValue= @(self.currentCornerRadius); 83 | shape.removedOnCompletion = FALSE; 84 | shape.fillMode = kCAFillModeForwards;; 85 | [self.layer addAnimation:shape forKey:@"re-shape"]; 86 | 87 | CABasicAnimation *sizing = [CABasicAnimation animationWithKeyPath:@"bounds"]; 88 | sizing.beginTime = CACurrentMediaTime() + (self.animationDuration * 3) / 5.0; 89 | sizing.duration= (self.animationDuration * 2) / 5.0; 90 | sizing.toValue= [NSValue valueWithCGRect:self.currentBounds]; 91 | sizing.removedOnCompletion = FALSE; 92 | sizing.fillMode = kCAFillModeForwards;; 93 | [self.layer addAnimation:sizing forKey:@"re-scale"]; 94 | } 95 | 96 | - (void)hideLoading { 97 | _isLoading = NO; 98 | [self.activity removeFromSuperview]; 99 | [self reShapeAnimation]; 100 | [self reEnable]; 101 | [self performSelector:@selector(resetText) withObject:nil afterDelay:self.animationDuration]; 102 | } 103 | 104 | - (void)reEnable { 105 | [self setEnabled:YES]; 106 | } 107 | 108 | - (void)resetText { 109 | [self setTitle:self.currentText forState:UIControlStateNormal]; 110 | } 111 | 112 | - (void)setFrameForActivity { 113 | [self.activity setCenter:self.center]; 114 | } 115 | 116 | -(void)layoutSubviews { 117 | [super layoutSubviews]; 118 | [self setFrameForActivity]; 119 | } 120 | @end 121 | -------------------------------------------------------------------------------- /SLButtonSample/SLButtonSample.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | A08B9D041BBC26520097D689 /* SLButton.m in Sources */ = {isa = PBXBuildFile; fileRef = A08B9D031BBC26520097D689 /* SLButton.m */; settings = {ASSET_TAGS = (); }; }; 11 | A09076341BBB27AE004B4DE8 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = A09076331BBB27AE004B4DE8 /* main.m */; }; 12 | A09076371BBB27AE004B4DE8 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = A09076361BBB27AE004B4DE8 /* AppDelegate.m */; }; 13 | A090763A1BBB27AE004B4DE8 /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = A09076391BBB27AE004B4DE8 /* ViewController.m */; }; 14 | A090763D1BBB27AE004B4DE8 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = A090763B1BBB27AE004B4DE8 /* Main.storyboard */; }; 15 | A090763F1BBB27AE004B4DE8 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = A090763E1BBB27AE004B4DE8 /* Assets.xcassets */; }; 16 | A09076421BBB27AE004B4DE8 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = A09076401BBB27AE004B4DE8 /* LaunchScreen.storyboard */; }; 17 | /* End PBXBuildFile section */ 18 | 19 | /* Begin PBXFileReference section */ 20 | A08B9D021BBC26520097D689 /* SLButton.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SLButton.h; sourceTree = ""; }; 21 | A08B9D031BBC26520097D689 /* SLButton.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SLButton.m; sourceTree = ""; }; 22 | A090762F1BBB27AE004B4DE8 /* SLButtonSample.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = SLButtonSample.app; sourceTree = BUILT_PRODUCTS_DIR; }; 23 | A09076331BBB27AE004B4DE8 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; 24 | A09076351BBB27AE004B4DE8 /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; 25 | A09076361BBB27AE004B4DE8 /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; }; 26 | A09076381BBB27AE004B4DE8 /* ViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ViewController.h; sourceTree = ""; }; 27 | A09076391BBB27AE004B4DE8 /* ViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ViewController.m; sourceTree = ""; }; 28 | A090763C1BBB27AE004B4DE8 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 29 | A090763E1BBB27AE004B4DE8 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 30 | A09076411BBB27AE004B4DE8 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 31 | A09076431BBB27AE004B4DE8 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 32 | /* End PBXFileReference section */ 33 | 34 | /* Begin PBXFrameworksBuildPhase section */ 35 | A090762C1BBB27AE004B4DE8 /* Frameworks */ = { 36 | isa = PBXFrameworksBuildPhase; 37 | buildActionMask = 2147483647; 38 | files = ( 39 | ); 40 | runOnlyForDeploymentPostprocessing = 0; 41 | }; 42 | /* End PBXFrameworksBuildPhase section */ 43 | 44 | /* Begin PBXGroup section */ 45 | A08B9D011BBC26520097D689 /* SLButton */ = { 46 | isa = PBXGroup; 47 | children = ( 48 | A08B9D021BBC26520097D689 /* SLButton.h */, 49 | A08B9D031BBC26520097D689 /* SLButton.m */, 50 | ); 51 | name = SLButton; 52 | path = ../../SLButton; 53 | sourceTree = ""; 54 | }; 55 | A09076261BBB27AE004B4DE8 = { 56 | isa = PBXGroup; 57 | children = ( 58 | A09076311BBB27AE004B4DE8 /* SLButtonSample */, 59 | A09076301BBB27AE004B4DE8 /* Products */, 60 | ); 61 | sourceTree = ""; 62 | }; 63 | A09076301BBB27AE004B4DE8 /* Products */ = { 64 | isa = PBXGroup; 65 | children = ( 66 | A090762F1BBB27AE004B4DE8 /* SLButtonSample.app */, 67 | ); 68 | name = Products; 69 | sourceTree = ""; 70 | }; 71 | A09076311BBB27AE004B4DE8 /* SLButtonSample */ = { 72 | isa = PBXGroup; 73 | children = ( 74 | A08B9D011BBC26520097D689 /* SLButton */, 75 | A09076351BBB27AE004B4DE8 /* AppDelegate.h */, 76 | A09076361BBB27AE004B4DE8 /* AppDelegate.m */, 77 | A09076381BBB27AE004B4DE8 /* ViewController.h */, 78 | A09076391BBB27AE004B4DE8 /* ViewController.m */, 79 | A090763B1BBB27AE004B4DE8 /* Main.storyboard */, 80 | A090763E1BBB27AE004B4DE8 /* Assets.xcassets */, 81 | A09076401BBB27AE004B4DE8 /* LaunchScreen.storyboard */, 82 | A09076431BBB27AE004B4DE8 /* Info.plist */, 83 | A09076321BBB27AE004B4DE8 /* Supporting Files */, 84 | ); 85 | path = SLButtonSample; 86 | sourceTree = ""; 87 | }; 88 | A09076321BBB27AE004B4DE8 /* Supporting Files */ = { 89 | isa = PBXGroup; 90 | children = ( 91 | A09076331BBB27AE004B4DE8 /* main.m */, 92 | ); 93 | name = "Supporting Files"; 94 | sourceTree = ""; 95 | }; 96 | /* End PBXGroup section */ 97 | 98 | /* Begin PBXNativeTarget section */ 99 | A090762E1BBB27AE004B4DE8 /* SLButtonSample */ = { 100 | isa = PBXNativeTarget; 101 | buildConfigurationList = A09076461BBB27AE004B4DE8 /* Build configuration list for PBXNativeTarget "SLButtonSample" */; 102 | buildPhases = ( 103 | A090762B1BBB27AE004B4DE8 /* Sources */, 104 | A090762C1BBB27AE004B4DE8 /* Frameworks */, 105 | A090762D1BBB27AE004B4DE8 /* Resources */, 106 | ); 107 | buildRules = ( 108 | ); 109 | dependencies = ( 110 | ); 111 | name = SLButtonSample; 112 | productName = SLButtonSample; 113 | productReference = A090762F1BBB27AE004B4DE8 /* SLButtonSample.app */; 114 | productType = "com.apple.product-type.application"; 115 | }; 116 | /* End PBXNativeTarget section */ 117 | 118 | /* Begin PBXProject section */ 119 | A09076271BBB27AE004B4DE8 /* Project object */ = { 120 | isa = PBXProject; 121 | attributes = { 122 | LastUpgradeCheck = 0700; 123 | ORGANIZATIONNAME = "Ali Pourhadi"; 124 | TargetAttributes = { 125 | A090762E1BBB27AE004B4DE8 = { 126 | CreatedOnToolsVersion = 7.0; 127 | }; 128 | }; 129 | }; 130 | buildConfigurationList = A090762A1BBB27AE004B4DE8 /* Build configuration list for PBXProject "SLButtonSample" */; 131 | compatibilityVersion = "Xcode 3.2"; 132 | developmentRegion = English; 133 | hasScannedForEncodings = 0; 134 | knownRegions = ( 135 | en, 136 | Base, 137 | ); 138 | mainGroup = A09076261BBB27AE004B4DE8; 139 | productRefGroup = A09076301BBB27AE004B4DE8 /* Products */; 140 | projectDirPath = ""; 141 | projectRoot = ""; 142 | targets = ( 143 | A090762E1BBB27AE004B4DE8 /* SLButtonSample */, 144 | ); 145 | }; 146 | /* End PBXProject section */ 147 | 148 | /* Begin PBXResourcesBuildPhase section */ 149 | A090762D1BBB27AE004B4DE8 /* Resources */ = { 150 | isa = PBXResourcesBuildPhase; 151 | buildActionMask = 2147483647; 152 | files = ( 153 | A09076421BBB27AE004B4DE8 /* LaunchScreen.storyboard in Resources */, 154 | A090763F1BBB27AE004B4DE8 /* Assets.xcassets in Resources */, 155 | A090763D1BBB27AE004B4DE8 /* Main.storyboard in Resources */, 156 | ); 157 | runOnlyForDeploymentPostprocessing = 0; 158 | }; 159 | /* End PBXResourcesBuildPhase section */ 160 | 161 | /* Begin PBXSourcesBuildPhase section */ 162 | A090762B1BBB27AE004B4DE8 /* Sources */ = { 163 | isa = PBXSourcesBuildPhase; 164 | buildActionMask = 2147483647; 165 | files = ( 166 | A08B9D041BBC26520097D689 /* SLButton.m in Sources */, 167 | A090763A1BBB27AE004B4DE8 /* ViewController.m in Sources */, 168 | A09076371BBB27AE004B4DE8 /* AppDelegate.m in Sources */, 169 | A09076341BBB27AE004B4DE8 /* main.m in Sources */, 170 | ); 171 | runOnlyForDeploymentPostprocessing = 0; 172 | }; 173 | /* End PBXSourcesBuildPhase section */ 174 | 175 | /* Begin PBXVariantGroup section */ 176 | A090763B1BBB27AE004B4DE8 /* Main.storyboard */ = { 177 | isa = PBXVariantGroup; 178 | children = ( 179 | A090763C1BBB27AE004B4DE8 /* Base */, 180 | ); 181 | name = Main.storyboard; 182 | sourceTree = ""; 183 | }; 184 | A09076401BBB27AE004B4DE8 /* LaunchScreen.storyboard */ = { 185 | isa = PBXVariantGroup; 186 | children = ( 187 | A09076411BBB27AE004B4DE8 /* Base */, 188 | ); 189 | name = LaunchScreen.storyboard; 190 | sourceTree = ""; 191 | }; 192 | /* End PBXVariantGroup section */ 193 | 194 | /* Begin XCBuildConfiguration section */ 195 | A09076441BBB27AE004B4DE8 /* Debug */ = { 196 | isa = XCBuildConfiguration; 197 | buildSettings = { 198 | ALWAYS_SEARCH_USER_PATHS = NO; 199 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 200 | CLANG_CXX_LIBRARY = "libc++"; 201 | CLANG_ENABLE_MODULES = YES; 202 | CLANG_ENABLE_OBJC_ARC = YES; 203 | CLANG_WARN_BOOL_CONVERSION = YES; 204 | CLANG_WARN_CONSTANT_CONVERSION = YES; 205 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 206 | CLANG_WARN_EMPTY_BODY = YES; 207 | CLANG_WARN_ENUM_CONVERSION = YES; 208 | CLANG_WARN_INT_CONVERSION = YES; 209 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 210 | CLANG_WARN_UNREACHABLE_CODE = YES; 211 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 212 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 213 | COPY_PHASE_STRIP = NO; 214 | DEBUG_INFORMATION_FORMAT = dwarf; 215 | ENABLE_STRICT_OBJC_MSGSEND = YES; 216 | ENABLE_TESTABILITY = YES; 217 | GCC_C_LANGUAGE_STANDARD = gnu99; 218 | GCC_DYNAMIC_NO_PIC = NO; 219 | GCC_NO_COMMON_BLOCKS = YES; 220 | GCC_OPTIMIZATION_LEVEL = 0; 221 | GCC_PREPROCESSOR_DEFINITIONS = ( 222 | "DEBUG=1", 223 | "$(inherited)", 224 | ); 225 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 226 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 227 | GCC_WARN_UNDECLARED_SELECTOR = YES; 228 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 229 | GCC_WARN_UNUSED_FUNCTION = YES; 230 | GCC_WARN_UNUSED_VARIABLE = YES; 231 | IPHONEOS_DEPLOYMENT_TARGET = 9.0; 232 | MTL_ENABLE_DEBUG_INFO = YES; 233 | ONLY_ACTIVE_ARCH = YES; 234 | SDKROOT = iphoneos; 235 | }; 236 | name = Debug; 237 | }; 238 | A09076451BBB27AE004B4DE8 /* Release */ = { 239 | isa = XCBuildConfiguration; 240 | buildSettings = { 241 | ALWAYS_SEARCH_USER_PATHS = NO; 242 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 243 | CLANG_CXX_LIBRARY = "libc++"; 244 | CLANG_ENABLE_MODULES = YES; 245 | CLANG_ENABLE_OBJC_ARC = YES; 246 | CLANG_WARN_BOOL_CONVERSION = YES; 247 | CLANG_WARN_CONSTANT_CONVERSION = YES; 248 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 249 | CLANG_WARN_EMPTY_BODY = YES; 250 | CLANG_WARN_ENUM_CONVERSION = YES; 251 | CLANG_WARN_INT_CONVERSION = YES; 252 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 253 | CLANG_WARN_UNREACHABLE_CODE = YES; 254 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 255 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 256 | COPY_PHASE_STRIP = NO; 257 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 258 | ENABLE_NS_ASSERTIONS = NO; 259 | ENABLE_STRICT_OBJC_MSGSEND = YES; 260 | GCC_C_LANGUAGE_STANDARD = gnu99; 261 | GCC_NO_COMMON_BLOCKS = YES; 262 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 263 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 264 | GCC_WARN_UNDECLARED_SELECTOR = YES; 265 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 266 | GCC_WARN_UNUSED_FUNCTION = YES; 267 | GCC_WARN_UNUSED_VARIABLE = YES; 268 | IPHONEOS_DEPLOYMENT_TARGET = 9.0; 269 | MTL_ENABLE_DEBUG_INFO = NO; 270 | SDKROOT = iphoneos; 271 | VALIDATE_PRODUCT = YES; 272 | }; 273 | name = Release; 274 | }; 275 | A09076471BBB27AE004B4DE8 /* Debug */ = { 276 | isa = XCBuildConfiguration; 277 | buildSettings = { 278 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 279 | INFOPLIST_FILE = SLButtonSample/Info.plist; 280 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 281 | PRODUCT_BUNDLE_IDENTIFIER = AliPourhadi.SLButtonSample; 282 | PRODUCT_NAME = "$(TARGET_NAME)"; 283 | }; 284 | name = Debug; 285 | }; 286 | A09076481BBB27AE004B4DE8 /* Release */ = { 287 | isa = XCBuildConfiguration; 288 | buildSettings = { 289 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 290 | INFOPLIST_FILE = SLButtonSample/Info.plist; 291 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 292 | PRODUCT_BUNDLE_IDENTIFIER = AliPourhadi.SLButtonSample; 293 | PRODUCT_NAME = "$(TARGET_NAME)"; 294 | }; 295 | name = Release; 296 | }; 297 | /* End XCBuildConfiguration section */ 298 | 299 | /* Begin XCConfigurationList section */ 300 | A090762A1BBB27AE004B4DE8 /* Build configuration list for PBXProject "SLButtonSample" */ = { 301 | isa = XCConfigurationList; 302 | buildConfigurations = ( 303 | A09076441BBB27AE004B4DE8 /* Debug */, 304 | A09076451BBB27AE004B4DE8 /* Release */, 305 | ); 306 | defaultConfigurationIsVisible = 0; 307 | defaultConfigurationName = Release; 308 | }; 309 | A09076461BBB27AE004B4DE8 /* Build configuration list for PBXNativeTarget "SLButtonSample" */ = { 310 | isa = XCConfigurationList; 311 | buildConfigurations = ( 312 | A09076471BBB27AE004B4DE8 /* Debug */, 313 | A09076481BBB27AE004B4DE8 /* Release */, 314 | ); 315 | defaultConfigurationIsVisible = 0; 316 | defaultConfigurationName = Release; 317 | }; 318 | /* End XCConfigurationList section */ 319 | }; 320 | rootObject = A09076271BBB27AE004B4DE8 /* Project object */; 321 | } 322 | -------------------------------------------------------------------------------- /SLButtonSample/SLButtonSample.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /SLButtonSample/SLButtonSample/AppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.h 3 | // SLButtonSample 4 | // 5 | // Created by Ali Pourhadi on 2015-09-29. 6 | // Copyright © 2015 Ali Pourhadi. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface AppDelegate : UIResponder 12 | 13 | @property (strong, nonatomic) UIWindow *window; 14 | 15 | 16 | @end 17 | 18 | -------------------------------------------------------------------------------- /SLButtonSample/SLButtonSample/AppDelegate.m: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.m 3 | // SLButtonSample 4 | // 5 | // Created by Ali Pourhadi on 2015-09-29. 6 | // Copyright © 2015 Ali Pourhadi. All rights reserved. 7 | // 8 | 9 | #import "AppDelegate.h" 10 | 11 | @interface AppDelegate () 12 | 13 | @end 14 | 15 | @implementation AppDelegate 16 | 17 | 18 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { 19 | // Override point for customization after application launch. 20 | return YES; 21 | } 22 | 23 | - (void)applicationWillResignActive:(UIApplication *)application { 24 | // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. 25 | // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game. 26 | } 27 | 28 | - (void)applicationDidEnterBackground:(UIApplication *)application { 29 | // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. 30 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 31 | } 32 | 33 | - (void)applicationWillEnterForeground:(UIApplication *)application { 34 | // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background. 35 | } 36 | 37 | - (void)applicationDidBecomeActive:(UIApplication *)application { 38 | // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. 39 | } 40 | 41 | - (void)applicationWillTerminate:(UIApplication *)application { 42 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 43 | } 44 | 45 | @end 46 | -------------------------------------------------------------------------------- /SLButtonSample/SLButtonSample/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "29x29", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "29x29", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "40x40", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "40x40", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "60x60", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "60x60", 31 | "scale" : "3x" 32 | } 33 | ], 34 | "info" : { 35 | "version" : 1, 36 | "author" : "xcode" 37 | } 38 | } -------------------------------------------------------------------------------- /SLButtonSample/SLButtonSample/Base.lproj/LaunchScreen.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /SLButtonSample/SLButtonSample/Base.lproj/Main.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 34 | 49 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | -------------------------------------------------------------------------------- /SLButtonSample/SLButtonSample/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | APPL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | LSRequiresIPhoneOS 24 | 25 | UILaunchStoryboardName 26 | LaunchScreen 27 | UIMainStoryboardFile 28 | Main 29 | UIRequiredDeviceCapabilities 30 | 31 | armv7 32 | 33 | UISupportedInterfaceOrientations 34 | 35 | UIInterfaceOrientationPortrait 36 | UIInterfaceOrientationLandscapeLeft 37 | UIInterfaceOrientationLandscapeRight 38 | 39 | 40 | 41 | -------------------------------------------------------------------------------- /SLButtonSample/SLButtonSample/ViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.h 3 | // SLButtonSample 4 | // 5 | // Created by Ali Pourhadi on 2015-09-29. 6 | // Copyright © 2015 Ali Pourhadi. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface ViewController : UIViewController 12 | 13 | 14 | @end 15 | 16 | -------------------------------------------------------------------------------- /SLButtonSample/SLButtonSample/ViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.m 3 | // SLButtonSample 4 | // 5 | // Created by Ali Pourhadi on 2015-09-29. 6 | // Copyright © 2015 Ali Pourhadi. All rights reserved. 7 | // 8 | 9 | #import "ViewController.h" 10 | #import "SLButton.h" 11 | 12 | @interface ViewController () 13 | 14 | @end 15 | 16 | @implementation ViewController 17 | 18 | - (void)viewDidLoad { 19 | [super viewDidLoad]; 20 | // Do any additional setup after loading the view, typically from a nib. 21 | } 22 | 23 | - (void)didReceiveMemoryWarning { 24 | [super didReceiveMemoryWarning]; 25 | // Dispose of any resources that can be recreated. 26 | } 27 | 28 | - (IBAction)buttonTapped:(SLButton *)sender { 29 | [sender showLoading]; 30 | [sender performSelector:@selector(hideLoading) withObject:nil afterDelay:3.0]; 31 | } 32 | 33 | @end 34 | -------------------------------------------------------------------------------- /SLButtonSample/SLButtonSample/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // SLButtonSample 4 | // 5 | // Created by Ali Pourhadi on 2015-09-29. 6 | // Copyright © 2015 Ali Pourhadi. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "AppDelegate.h" 11 | 12 | int main(int argc, char * argv[]) { 13 | @autoreleasepool { 14 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /ScreenShot-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PersianDevelopers/SLButton/4385f125c4f040ba671a29a4d209e6bd69d88ad9/ScreenShot-1.png -------------------------------------------------------------------------------- /ScreenShot-2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PersianDevelopers/SLButton/4385f125c4f040ba671a29a4d209e6bd69d88ad9/ScreenShot-2.png --------------------------------------------------------------------------------