├── .gitignore ├── Classes ├── MMPulseView.h └── MMPulseView.m ├── LICENSE ├── MMPulseView.podspec ├── MMPulseView ├── MMPulseView.xcodeproj │ ├── project.pbxproj │ └── project.xcworkspace │ │ └── contents.xcworkspacedata └── MMPulseView │ ├── AppDelegate.h │ ├── AppDelegate.m │ ├── Assets.xcassets │ └── AppIcon.appiconset │ │ └── Contents.json │ ├── Base.lproj │ ├── LaunchScreen.storyboard │ └── Main.storyboard │ ├── Info.plist │ ├── ViewController.h │ ├── ViewController.m │ ├── button@2x.png │ ├── button@3x.png │ └── main.m ├── README.md └── demo.gif /.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 | 20 | # CocoaPods 21 | # 22 | # We recommend against adding the Pods directory to your .gitignore. However 23 | # you should judge for yourself, the pros and cons are mentioned at: 24 | # http://guides.cocoapods.org/using/using-cocoapods.html#should-i-ignore-the-pods-directory-in-source-control 25 | # 26 | #Pods/ 27 | -------------------------------------------------------------------------------- /Classes/MMPulseView.h: -------------------------------------------------------------------------------- 1 | // 2 | // MMPulseView.h 3 | // MMPulseView 4 | // 5 | // Created by Ralph Li on 12/29/15. 6 | // Copyright © 2015 LJC. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface MMPulseView : UIView 12 | 13 | //gradient layer property 14 | @property (nonatomic, copy ) NSArray *colors; 15 | @property (nonatomic, copy ) NSArray *locations; 16 | @property (nonatomic, assign) CGPoint startPoint; 17 | @property (nonatomic, assign) CGPoint endPoint; 18 | 19 | //replicator layer property 20 | @property (nonatomic, assign) NSUInteger count; 21 | @property (nonatomic, assign) CGFloat duration; 22 | 23 | //circle layer property 24 | @property (nonatomic, assign) CGFloat minRadius; 25 | @property (nonatomic, assign) CGFloat maxRadius; 26 | @property (nonatomic, assign) CGFloat lineWidth; 27 | 28 | //animation property 29 | @property (nonatomic, strong) CAMediaTimingFunction *timingFunction; 30 | 31 | - (void)startAnimation; 32 | - (void)stopAnimation; 33 | 34 | @end 35 | -------------------------------------------------------------------------------- /Classes/MMPulseView.m: -------------------------------------------------------------------------------- 1 | // 2 | // MMPulseView.m 3 | // MMPulseView 4 | // 5 | // Created by Ralph Li on 12/29/15. 6 | // Copyright © 2015 LJC. All rights reserved. 7 | // 8 | 9 | #import "MMPulseView.h" 10 | 11 | @interface MMPulseView() 12 | 13 | @property (nonatomic, strong) CAGradientLayer *gradientLayer; 14 | @property (nonatomic, strong) CAReplicatorLayer *replicatorLayer; 15 | @property (nonatomic, strong) CAShapeLayer *circleLayer; 16 | 17 | @end 18 | 19 | @implementation MMPulseView 20 | 21 | 22 | - (instancetype)init 23 | { 24 | self = [super init]; 25 | if ( self ) 26 | { 27 | self.gradientLayer = ({ 28 | CAGradientLayer *layer = [CAGradientLayer new]; 29 | 30 | [self.layer addSublayer:layer]; 31 | 32 | layer; 33 | }); 34 | 35 | self.replicatorLayer = ({ 36 | CAReplicatorLayer *layer = [CAReplicatorLayer new]; 37 | 38 | self.gradientLayer.mask = layer; 39 | 40 | layer; 41 | }); 42 | 43 | self.circleLayer = ({ 44 | CAShapeLayer *layer = [CAShapeLayer new]; 45 | layer.strokeColor = [UIColor whiteColor].CGColor; 46 | layer.fillColor = [UIColor clearColor].CGColor; 47 | 48 | [self.replicatorLayer addSublayer:layer]; 49 | 50 | layer; 51 | }); 52 | 53 | self.minRadius = 10; 54 | self.maxRadius = 100; 55 | 56 | self.duration = 3.0f; 57 | self.count = 6; 58 | self.lineWidth = 2.0f; 59 | 60 | self.colors = @[(__bridge id)[UIColor orangeColor].CGColor,(__bridge id)[UIColor orangeColor].CGColor]; 61 | 62 | self.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseOut]; 63 | } 64 | return self; 65 | } 66 | 67 | - (void)setColors:(NSArray *)colors 68 | { 69 | self.gradientLayer.colors = colors; 70 | } 71 | 72 | - (NSArray *)colors 73 | { 74 | return self.gradientLayer.colors; 75 | } 76 | 77 | - (void)setLocations:(NSArray *)locations 78 | { 79 | self.gradientLayer.locations = locations; 80 | } 81 | 82 | - (NSArray *)locations 83 | { 84 | return self.gradientLayer.locations; 85 | } 86 | 87 | - (void)setStartPoint:(CGPoint)startPoint 88 | { 89 | self.gradientLayer.startPoint = startPoint; 90 | } 91 | 92 | - (CGPoint)startPoint 93 | { 94 | return self.gradientLayer.startPoint; 95 | } 96 | 97 | - (void)setEndPoint:(CGPoint)endPoint 98 | { 99 | self.gradientLayer.endPoint = endPoint; 100 | } 101 | 102 | - (CGPoint)endPoint 103 | { 104 | return self.gradientLayer.endPoint; 105 | } 106 | 107 | - (void)setDuration:(CGFloat)duration 108 | { 109 | _duration = duration; 110 | 111 | if ( _count != 0 ) 112 | { 113 | self.replicatorLayer.instanceCount = _count; 114 | self.replicatorLayer.instanceDelay = self.duration/(CGFloat)_count; 115 | } 116 | } 117 | 118 | - (void)setCount:(NSUInteger)count 119 | { 120 | _count = count; 121 | 122 | if ( _count != 0 ) 123 | { 124 | self.replicatorLayer.instanceCount = _count; 125 | self.replicatorLayer.instanceDelay = self.duration/(CGFloat)_count; 126 | } 127 | } 128 | 129 | - (void)setLineWidth:(CGFloat)lineWidth 130 | { 131 | _lineWidth = lineWidth; 132 | 133 | self.circleLayer.lineWidth = lineWidth; 134 | } 135 | 136 | - (void)layoutSubviews 137 | { 138 | [super layoutSubviews]; 139 | 140 | self.gradientLayer.frame = self.bounds; 141 | self.replicatorLayer.frame = self.bounds; 142 | self.circleLayer.frame = self.bounds; 143 | } 144 | 145 | - (void)startAnimation 146 | { 147 | CGRect fromRect = CGRectMake(CGRectGetMidX(self.bounds)-self.minRadius, CGRectGetMidY(self.bounds)-self.minRadius, self.minRadius*2, self.minRadius*2); 148 | CGRect toRect = CGRectMake(CGRectGetMidX(self.bounds)-self.maxRadius, CGRectGetMidY(self.bounds)-self.maxRadius, self.maxRadius*2, self.maxRadius*2); 149 | 150 | CABasicAnimation *zoomAnimation = [CABasicAnimation animationWithKeyPath:@"path"]; 151 | zoomAnimation.duration = self.duration; 152 | zoomAnimation.fromValue = (__bridge id)[UIBezierPath bezierPathWithOvalInRect:fromRect].CGPath; 153 | zoomAnimation.toValue = (__bridge id)[UIBezierPath bezierPathWithOvalInRect:toRect].CGPath; 154 | zoomAnimation.repeatCount = HUGE_VAL; 155 | zoomAnimation.timingFunction = self.timingFunction; 156 | [self.circleLayer addAnimation:zoomAnimation forKey:@"zoom"]; 157 | 158 | CABasicAnimation *fadeAnimation = [CABasicAnimation animationWithKeyPath:@"strokeColor"]; 159 | fadeAnimation.duration = self.duration; 160 | fadeAnimation.fromValue = (__bridge id)[UIColor whiteColor].CGColor; 161 | fadeAnimation.toValue = (__bridge id)[UIColor clearColor].CGColor; 162 | fadeAnimation.repeatCount = HUGE_VAL; 163 | fadeAnimation.timingFunction = self.timingFunction; 164 | [self.circleLayer addAnimation:fadeAnimation forKey:@"fade"]; 165 | } 166 | 167 | - (void)stopAnimation 168 | { 169 | [self.circleLayer removeAllAnimations]; 170 | } 171 | 172 | @end 173 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015 ralph li 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 | -------------------------------------------------------------------------------- /MMPulseView.podspec: -------------------------------------------------------------------------------- 1 | Pod::Spec.new do |s| 2 | s.name = "MMPulseView" 3 | s.version = "1.0" 4 | s.summary = "A simple view to show circle pulse repeatly." 5 | s.homepage = "https://github.com/adad184/MMPulseView" 6 | s.license = { :type => 'MIT License', :file => 'LICENSE' } 7 | s.author = { "adad184" => "adad184@gmail.com" } 8 | s.source = { :git => "https://github.com/adad184/MMPulseView.git", :tag => "1.0" } 9 | s.platform = :ios, '7.0' 10 | s.source_files = 'Classes/*.{h,m}' 11 | s.requires_arc = true 12 | end 13 | -------------------------------------------------------------------------------- /MMPulseView/MMPulseView.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | ED3B97721C32801400C68601 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = ED3B97711C32801400C68601 /* main.m */; }; 11 | ED3B97751C32801400C68601 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = ED3B97741C32801400C68601 /* AppDelegate.m */; }; 12 | ED3B97781C32801400C68601 /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = ED3B97771C32801400C68601 /* ViewController.m */; }; 13 | ED3B977B1C32801400C68601 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = ED3B97791C32801400C68601 /* Main.storyboard */; }; 14 | ED3B977D1C32801400C68601 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = ED3B977C1C32801400C68601 /* Assets.xcassets */; }; 15 | ED3B97801C32801400C68601 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = ED3B977E1C32801400C68601 /* LaunchScreen.storyboard */; }; 16 | ED3B978A1C32804900C68601 /* MMPulseView.m in Sources */ = {isa = PBXBuildFile; fileRef = ED3B97891C32804900C68601 /* MMPulseView.m */; }; 17 | EDC3AACB1C336AF60039BB5A /* button@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = EDC3AAC91C336AF60039BB5A /* button@2x.png */; }; 18 | EDC3AACC1C336AF60039BB5A /* button@3x.png in Resources */ = {isa = PBXBuildFile; fileRef = EDC3AACA1C336AF60039BB5A /* button@3x.png */; }; 19 | /* End PBXBuildFile section */ 20 | 21 | /* Begin PBXFileReference section */ 22 | ED3B976D1C32801400C68601 /* MMPulseView.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = MMPulseView.app; sourceTree = BUILT_PRODUCTS_DIR; }; 23 | ED3B97711C32801400C68601 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; 24 | ED3B97731C32801400C68601 /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; 25 | ED3B97741C32801400C68601 /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; }; 26 | ED3B97761C32801400C68601 /* ViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ViewController.h; sourceTree = ""; }; 27 | ED3B97771C32801400C68601 /* ViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ViewController.m; sourceTree = ""; }; 28 | ED3B977A1C32801400C68601 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 29 | ED3B977C1C32801400C68601 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 30 | ED3B977F1C32801400C68601 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 31 | ED3B97811C32801400C68601 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 32 | ED3B97881C32804900C68601 /* MMPulseView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MMPulseView.h; sourceTree = ""; }; 33 | ED3B97891C32804900C68601 /* MMPulseView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MMPulseView.m; sourceTree = ""; }; 34 | EDC3AAC91C336AF60039BB5A /* button@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "button@2x.png"; sourceTree = ""; }; 35 | EDC3AACA1C336AF60039BB5A /* button@3x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "button@3x.png"; sourceTree = ""; }; 36 | /* End PBXFileReference section */ 37 | 38 | /* Begin PBXFrameworksBuildPhase section */ 39 | ED3B976A1C32801400C68601 /* Frameworks */ = { 40 | isa = PBXFrameworksBuildPhase; 41 | buildActionMask = 2147483647; 42 | files = ( 43 | ); 44 | runOnlyForDeploymentPostprocessing = 0; 45 | }; 46 | /* End PBXFrameworksBuildPhase section */ 47 | 48 | /* Begin PBXGroup section */ 49 | ED3B97641C32801400C68601 = { 50 | isa = PBXGroup; 51 | children = ( 52 | ED3B97871C32803300C68601 /* Classes */, 53 | ED3B976F1C32801400C68601 /* MMPulseView */, 54 | ED3B976E1C32801400C68601 /* Products */, 55 | ); 56 | sourceTree = ""; 57 | }; 58 | ED3B976E1C32801400C68601 /* Products */ = { 59 | isa = PBXGroup; 60 | children = ( 61 | ED3B976D1C32801400C68601 /* MMPulseView.app */, 62 | ); 63 | name = Products; 64 | sourceTree = ""; 65 | }; 66 | ED3B976F1C32801400C68601 /* MMPulseView */ = { 67 | isa = PBXGroup; 68 | children = ( 69 | ED3B97731C32801400C68601 /* AppDelegate.h */, 70 | ED3B97741C32801400C68601 /* AppDelegate.m */, 71 | ED3B97761C32801400C68601 /* ViewController.h */, 72 | ED3B97771C32801400C68601 /* ViewController.m */, 73 | EDC3AAC91C336AF60039BB5A /* button@2x.png */, 74 | EDC3AACA1C336AF60039BB5A /* button@3x.png */, 75 | ED3B97791C32801400C68601 /* Main.storyboard */, 76 | ED3B977C1C32801400C68601 /* Assets.xcassets */, 77 | ED3B977E1C32801400C68601 /* LaunchScreen.storyboard */, 78 | ED3B97811C32801400C68601 /* Info.plist */, 79 | ED3B97701C32801400C68601 /* Supporting Files */, 80 | ); 81 | path = MMPulseView; 82 | sourceTree = ""; 83 | }; 84 | ED3B97701C32801400C68601 /* Supporting Files */ = { 85 | isa = PBXGroup; 86 | children = ( 87 | ED3B97711C32801400C68601 /* main.m */, 88 | ); 89 | name = "Supporting Files"; 90 | sourceTree = ""; 91 | }; 92 | ED3B97871C32803300C68601 /* Classes */ = { 93 | isa = PBXGroup; 94 | children = ( 95 | ED3B97881C32804900C68601 /* MMPulseView.h */, 96 | ED3B97891C32804900C68601 /* MMPulseView.m */, 97 | ); 98 | name = Classes; 99 | path = ../Classes; 100 | sourceTree = ""; 101 | }; 102 | /* End PBXGroup section */ 103 | 104 | /* Begin PBXNativeTarget section */ 105 | ED3B976C1C32801400C68601 /* MMPulseView */ = { 106 | isa = PBXNativeTarget; 107 | buildConfigurationList = ED3B97841C32801400C68601 /* Build configuration list for PBXNativeTarget "MMPulseView" */; 108 | buildPhases = ( 109 | ED3B97691C32801400C68601 /* Sources */, 110 | ED3B976A1C32801400C68601 /* Frameworks */, 111 | ED3B976B1C32801400C68601 /* Resources */, 112 | ); 113 | buildRules = ( 114 | ); 115 | dependencies = ( 116 | ); 117 | name = MMPulseView; 118 | productName = MMPulseView; 119 | productReference = ED3B976D1C32801400C68601 /* MMPulseView.app */; 120 | productType = "com.apple.product-type.application"; 121 | }; 122 | /* End PBXNativeTarget section */ 123 | 124 | /* Begin PBXProject section */ 125 | ED3B97651C32801400C68601 /* Project object */ = { 126 | isa = PBXProject; 127 | attributes = { 128 | LastUpgradeCheck = 0720; 129 | ORGANIZATIONNAME = LJC; 130 | TargetAttributes = { 131 | ED3B976C1C32801400C68601 = { 132 | CreatedOnToolsVersion = 7.2; 133 | }; 134 | }; 135 | }; 136 | buildConfigurationList = ED3B97681C32801400C68601 /* Build configuration list for PBXProject "MMPulseView" */; 137 | compatibilityVersion = "Xcode 3.2"; 138 | developmentRegion = English; 139 | hasScannedForEncodings = 0; 140 | knownRegions = ( 141 | en, 142 | Base, 143 | ); 144 | mainGroup = ED3B97641C32801400C68601; 145 | productRefGroup = ED3B976E1C32801400C68601 /* Products */; 146 | projectDirPath = ""; 147 | projectRoot = ""; 148 | targets = ( 149 | ED3B976C1C32801400C68601 /* MMPulseView */, 150 | ); 151 | }; 152 | /* End PBXProject section */ 153 | 154 | /* Begin PBXResourcesBuildPhase section */ 155 | ED3B976B1C32801400C68601 /* Resources */ = { 156 | isa = PBXResourcesBuildPhase; 157 | buildActionMask = 2147483647; 158 | files = ( 159 | ED3B97801C32801400C68601 /* LaunchScreen.storyboard in Resources */, 160 | ED3B977D1C32801400C68601 /* Assets.xcassets in Resources */, 161 | EDC3AACC1C336AF60039BB5A /* button@3x.png in Resources */, 162 | EDC3AACB1C336AF60039BB5A /* button@2x.png in Resources */, 163 | ED3B977B1C32801400C68601 /* Main.storyboard in Resources */, 164 | ); 165 | runOnlyForDeploymentPostprocessing = 0; 166 | }; 167 | /* End PBXResourcesBuildPhase section */ 168 | 169 | /* Begin PBXSourcesBuildPhase section */ 170 | ED3B97691C32801400C68601 /* Sources */ = { 171 | isa = PBXSourcesBuildPhase; 172 | buildActionMask = 2147483647; 173 | files = ( 174 | ED3B97781C32801400C68601 /* ViewController.m in Sources */, 175 | ED3B97751C32801400C68601 /* AppDelegate.m in Sources */, 176 | ED3B978A1C32804900C68601 /* MMPulseView.m in Sources */, 177 | ED3B97721C32801400C68601 /* main.m in Sources */, 178 | ); 179 | runOnlyForDeploymentPostprocessing = 0; 180 | }; 181 | /* End PBXSourcesBuildPhase section */ 182 | 183 | /* Begin PBXVariantGroup section */ 184 | ED3B97791C32801400C68601 /* Main.storyboard */ = { 185 | isa = PBXVariantGroup; 186 | children = ( 187 | ED3B977A1C32801400C68601 /* Base */, 188 | ); 189 | name = Main.storyboard; 190 | sourceTree = ""; 191 | }; 192 | ED3B977E1C32801400C68601 /* LaunchScreen.storyboard */ = { 193 | isa = PBXVariantGroup; 194 | children = ( 195 | ED3B977F1C32801400C68601 /* Base */, 196 | ); 197 | name = LaunchScreen.storyboard; 198 | sourceTree = ""; 199 | }; 200 | /* End PBXVariantGroup section */ 201 | 202 | /* Begin XCBuildConfiguration section */ 203 | ED3B97821C32801400C68601 /* Debug */ = { 204 | isa = XCBuildConfiguration; 205 | buildSettings = { 206 | ALWAYS_SEARCH_USER_PATHS = NO; 207 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 208 | CLANG_CXX_LIBRARY = "libc++"; 209 | CLANG_ENABLE_MODULES = YES; 210 | CLANG_ENABLE_OBJC_ARC = YES; 211 | CLANG_WARN_BOOL_CONVERSION = YES; 212 | CLANG_WARN_CONSTANT_CONVERSION = YES; 213 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 214 | CLANG_WARN_EMPTY_BODY = YES; 215 | CLANG_WARN_ENUM_CONVERSION = YES; 216 | CLANG_WARN_INT_CONVERSION = YES; 217 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 218 | CLANG_WARN_UNREACHABLE_CODE = YES; 219 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 220 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 221 | COPY_PHASE_STRIP = NO; 222 | DEBUG_INFORMATION_FORMAT = dwarf; 223 | ENABLE_STRICT_OBJC_MSGSEND = YES; 224 | ENABLE_TESTABILITY = YES; 225 | GCC_C_LANGUAGE_STANDARD = gnu99; 226 | GCC_DYNAMIC_NO_PIC = NO; 227 | GCC_NO_COMMON_BLOCKS = YES; 228 | GCC_OPTIMIZATION_LEVEL = 0; 229 | GCC_PREPROCESSOR_DEFINITIONS = ( 230 | "DEBUG=1", 231 | "$(inherited)", 232 | ); 233 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 234 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 235 | GCC_WARN_UNDECLARED_SELECTOR = YES; 236 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 237 | GCC_WARN_UNUSED_FUNCTION = YES; 238 | GCC_WARN_UNUSED_VARIABLE = YES; 239 | IPHONEOS_DEPLOYMENT_TARGET = 9.2; 240 | MTL_ENABLE_DEBUG_INFO = YES; 241 | ONLY_ACTIVE_ARCH = YES; 242 | SDKROOT = iphoneos; 243 | TARGETED_DEVICE_FAMILY = "1,2"; 244 | }; 245 | name = Debug; 246 | }; 247 | ED3B97831C32801400C68601 /* Release */ = { 248 | isa = XCBuildConfiguration; 249 | buildSettings = { 250 | ALWAYS_SEARCH_USER_PATHS = NO; 251 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 252 | CLANG_CXX_LIBRARY = "libc++"; 253 | CLANG_ENABLE_MODULES = YES; 254 | CLANG_ENABLE_OBJC_ARC = YES; 255 | CLANG_WARN_BOOL_CONVERSION = YES; 256 | CLANG_WARN_CONSTANT_CONVERSION = YES; 257 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 258 | CLANG_WARN_EMPTY_BODY = YES; 259 | CLANG_WARN_ENUM_CONVERSION = YES; 260 | CLANG_WARN_INT_CONVERSION = YES; 261 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 262 | CLANG_WARN_UNREACHABLE_CODE = YES; 263 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 264 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 265 | COPY_PHASE_STRIP = NO; 266 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 267 | ENABLE_NS_ASSERTIONS = NO; 268 | ENABLE_STRICT_OBJC_MSGSEND = YES; 269 | GCC_C_LANGUAGE_STANDARD = gnu99; 270 | GCC_NO_COMMON_BLOCKS = YES; 271 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 272 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 273 | GCC_WARN_UNDECLARED_SELECTOR = YES; 274 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 275 | GCC_WARN_UNUSED_FUNCTION = YES; 276 | GCC_WARN_UNUSED_VARIABLE = YES; 277 | IPHONEOS_DEPLOYMENT_TARGET = 9.2; 278 | MTL_ENABLE_DEBUG_INFO = NO; 279 | SDKROOT = iphoneos; 280 | TARGETED_DEVICE_FAMILY = "1,2"; 281 | VALIDATE_PRODUCT = YES; 282 | }; 283 | name = Release; 284 | }; 285 | ED3B97851C32801400C68601 /* Debug */ = { 286 | isa = XCBuildConfiguration; 287 | buildSettings = { 288 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 289 | INFOPLIST_FILE = MMPulseView/Info.plist; 290 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 291 | PRODUCT_BUNDLE_IDENTIFIER = com.adad184.MMPulseView; 292 | PRODUCT_NAME = "$(TARGET_NAME)"; 293 | }; 294 | name = Debug; 295 | }; 296 | ED3B97861C32801400C68601 /* Release */ = { 297 | isa = XCBuildConfiguration; 298 | buildSettings = { 299 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 300 | INFOPLIST_FILE = MMPulseView/Info.plist; 301 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 302 | PRODUCT_BUNDLE_IDENTIFIER = com.adad184.MMPulseView; 303 | PRODUCT_NAME = "$(TARGET_NAME)"; 304 | }; 305 | name = Release; 306 | }; 307 | /* End XCBuildConfiguration section */ 308 | 309 | /* Begin XCConfigurationList section */ 310 | ED3B97681C32801400C68601 /* Build configuration list for PBXProject "MMPulseView" */ = { 311 | isa = XCConfigurationList; 312 | buildConfigurations = ( 313 | ED3B97821C32801400C68601 /* Debug */, 314 | ED3B97831C32801400C68601 /* Release */, 315 | ); 316 | defaultConfigurationIsVisible = 0; 317 | defaultConfigurationName = Release; 318 | }; 319 | ED3B97841C32801400C68601 /* Build configuration list for PBXNativeTarget "MMPulseView" */ = { 320 | isa = XCConfigurationList; 321 | buildConfigurations = ( 322 | ED3B97851C32801400C68601 /* Debug */, 323 | ED3B97861C32801400C68601 /* Release */, 324 | ); 325 | defaultConfigurationIsVisible = 0; 326 | defaultConfigurationName = Release; 327 | }; 328 | /* End XCConfigurationList section */ 329 | }; 330 | rootObject = ED3B97651C32801400C68601 /* Project object */; 331 | } 332 | -------------------------------------------------------------------------------- /MMPulseView/MMPulseView.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /MMPulseView/MMPulseView/AppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.h 3 | // MMPulseView 4 | // 5 | // Created by Ralph Li on 12/29/15. 6 | // Copyright © 2015 LJC. 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 | -------------------------------------------------------------------------------- /MMPulseView/MMPulseView/AppDelegate.m: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.m 3 | // MMPulseView 4 | // 5 | // Created by Ralph Li on 12/29/15. 6 | // Copyright © 2015 LJC. 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 | -------------------------------------------------------------------------------- /MMPulseView/MMPulseView/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "29x29", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "29x29", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "40x40", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "40x40", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "60x60", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "60x60", 31 | "scale" : "3x" 32 | }, 33 | { 34 | "idiom" : "ipad", 35 | "size" : "29x29", 36 | "scale" : "1x" 37 | }, 38 | { 39 | "idiom" : "ipad", 40 | "size" : "29x29", 41 | "scale" : "2x" 42 | }, 43 | { 44 | "idiom" : "ipad", 45 | "size" : "40x40", 46 | "scale" : "1x" 47 | }, 48 | { 49 | "idiom" : "ipad", 50 | "size" : "40x40", 51 | "scale" : "2x" 52 | }, 53 | { 54 | "idiom" : "ipad", 55 | "size" : "76x76", 56 | "scale" : "1x" 57 | }, 58 | { 59 | "idiom" : "ipad", 60 | "size" : "76x76", 61 | "scale" : "2x" 62 | } 63 | ], 64 | "info" : { 65 | "version" : 1, 66 | "author" : "xcode" 67 | } 68 | } -------------------------------------------------------------------------------- /MMPulseView/MMPulseView/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 | -------------------------------------------------------------------------------- /MMPulseView/MMPulseView/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 | -------------------------------------------------------------------------------- /MMPulseView/MMPulseView/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 | UIStatusBarHidden 34 | 35 | UISupportedInterfaceOrientations 36 | 37 | UIInterfaceOrientationPortrait 38 | UIInterfaceOrientationLandscapeLeft 39 | UIInterfaceOrientationLandscapeRight 40 | 41 | UISupportedInterfaceOrientations~ipad 42 | 43 | UIInterfaceOrientationPortrait 44 | UIInterfaceOrientationPortraitUpsideDown 45 | UIInterfaceOrientationLandscapeLeft 46 | UIInterfaceOrientationLandscapeRight 47 | 48 | 49 | 50 | -------------------------------------------------------------------------------- /MMPulseView/MMPulseView/ViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.h 3 | // MMPulseView 4 | // 5 | // Created by Ralph Li on 12/29/15. 6 | // Copyright © 2015 LJC. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface ViewController : UIViewController 12 | 13 | 14 | @end 15 | 16 | -------------------------------------------------------------------------------- /MMPulseView/MMPulseView/ViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.m 3 | // MMPulseView 4 | // 5 | // Created by Ralph Li on 12/29/15. 6 | // Copyright © 2015 LJC. All rights reserved. 7 | // 8 | 9 | #import "ViewController.h" 10 | #import "MMPulseView.h" 11 | 12 | @interface ViewController () 13 | 14 | @property (nonatomic, strong) NSArray *pulseArray; 15 | 16 | @end 17 | 18 | @implementation ViewController 19 | 20 | - (void)viewDidLoad { 21 | [super viewDidLoad]; 22 | // Do any additional setup after loading the view, typically from a nib. 23 | 24 | NSInteger maxI = 2; 25 | NSInteger maxJ = 2; 26 | 27 | NSMutableArray *pulseArray = @[].mutableCopy; 28 | 29 | for ( int i = 0 ; i < maxI*maxJ ; ++i ) 30 | { 31 | [pulseArray addObject:[MMPulseView new]]; 32 | } 33 | self.pulseArray = pulseArray; 34 | 35 | CGRect screenRect = [UIScreen mainScreen].bounds; 36 | 37 | for ( int i = 0 ; i < maxI ; ++i ) 38 | { 39 | for ( int j = 0 ; j < maxJ ; ++j ) 40 | { 41 | NSInteger index = i*maxJ+j; 42 | MMPulseView *pulseView = pulseArray[index]; 43 | 44 | pulseView.frame = CGRectMake(CGRectGetWidth(screenRect)/maxJ*j, 45 | CGRectGetHeight(screenRect)/maxI*i, 46 | CGRectGetWidth(screenRect)/maxJ, 47 | CGRectGetHeight(screenRect)/maxI); 48 | 49 | [self.view addSubview:pulseView]; 50 | 51 | 52 | switch (index) { 53 | case 0: 54 | { 55 | pulseView.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionLinear]; 56 | pulseView.colors = @[(__bridge id)[UIColor blueColor].CGColor,(__bridge id)[UIColor blueColor].CGColor]; 57 | 58 | pulseView.minRadius = 0; 59 | pulseView.maxRadius = 80; 60 | 61 | pulseView.duration = 5; 62 | pulseView.count = 20; 63 | pulseView.lineWidth = 1.0f; 64 | 65 | break; 66 | } 67 | case 1: 68 | { 69 | pulseView.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseIn]; 70 | pulseView.colors = @[(__bridge id)[UIColor colorWithRed:0.996 green:0.647 blue:0.008 alpha:1].CGColor,(__bridge id)[UIColor colorWithRed:1 green:0.31 blue:0.349 alpha:1].CGColor]; 71 | 72 | CGFloat posY = (CGRectGetHeight(screenRect)-320)/2/CGRectGetHeight(screenRect); 73 | pulseView.startPoint = CGPointMake(0.5, posY); 74 | pulseView.endPoint = CGPointMake(0.5, 1.0f - posY); 75 | 76 | pulseView.minRadius = 40; 77 | pulseView.maxRadius = 100; 78 | 79 | pulseView.duration = 2; 80 | pulseView.count = 4; 81 | pulseView.lineWidth = 2.0f; 82 | 83 | UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom]; 84 | [self.view addSubview:btn]; 85 | [btn setBackgroundImage:[UIImage imageNamed:@"button"] forState:UIControlStateNormal]; 86 | [btn setTitle:@"Tap" forState:UIControlStateNormal]; 87 | btn.frame = CGRectMake(0, 0, 100, 100); 88 | btn.center = pulseView.center; 89 | [btn addTarget:self action:@selector(actionPulse) forControlEvents:UIControlEventTouchUpInside]; 90 | 91 | break; 92 | } 93 | case 2: 94 | { 95 | pulseView.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseOut]; 96 | pulseView.colors = @[(__bridge id)[UIColor redColor].CGColor, (__bridge id)[UIColor blueColor].CGColor]; 97 | pulseView.startPoint = CGPointMake(0, 0.5); 98 | pulseView.endPoint = CGPointMake(1, 0.5); 99 | 100 | pulseView.minRadius = 0; 101 | pulseView.maxRadius = 60; 102 | 103 | pulseView.duration = 5; 104 | pulseView.count = 1; 105 | pulseView.lineWidth = 5.0f; 106 | 107 | break; 108 | } 109 | case 3: 110 | { 111 | pulseView.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]; 112 | pulseView.colors = @[(__bridge id)[UIColor whiteColor].CGColor, 113 | (__bridge id)[UIColor blackColor].CGColor, 114 | (__bridge id)[UIColor whiteColor].CGColor]; 115 | pulseView.locations = @[@(0.3),@(0.5),@(0.7)]; 116 | pulseView.startPoint = CGPointMake(0, 0.5); 117 | pulseView.endPoint = CGPointMake(1, 0.5); 118 | 119 | pulseView.minRadius = 0; 120 | pulseView.maxRadius = 100; 121 | 122 | pulseView.duration = 3; 123 | pulseView.count = 6; 124 | pulseView.lineWidth = 3.0f; 125 | 126 | break; 127 | } 128 | 129 | default: 130 | break; 131 | } 132 | 133 | if ( index != 1 ) 134 | { 135 | [pulseView startAnimation]; 136 | } 137 | } 138 | } 139 | } 140 | 141 | - (void)actionPulse 142 | { 143 | MMPulseView *pulseView = self.pulseArray[1]; 144 | 145 | pulseView.tag = 1 - pulseView.tag; 146 | 147 | (pulseView.tag>0)?[pulseView startAnimation]:[pulseView stopAnimation]; 148 | } 149 | 150 | - (void)didReceiveMemoryWarning { 151 | [super didReceiveMemoryWarning]; 152 | // Dispose of any resources that can be recreated. 153 | } 154 | 155 | - (BOOL)prefersStatusBarHidden 156 | { 157 | return YES; 158 | } 159 | 160 | @end 161 | -------------------------------------------------------------------------------- /MMPulseView/MMPulseView/button@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/adad184/MMPulseView/17a9616616298aef33d391a4d28a537a71f1cffe/MMPulseView/MMPulseView/button@2x.png -------------------------------------------------------------------------------- /MMPulseView/MMPulseView/button@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/adad184/MMPulseView/17a9616616298aef33d391a4d28a537a71f1cffe/MMPulseView/MMPulseView/button@3x.png -------------------------------------------------------------------------------- /MMPulseView/MMPulseView/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // MMPulseView 4 | // 5 | // Created by Ralph Li on 12/29/15. 6 | // Copyright © 2015 LJC. 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 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | MMPulseView 2 | ============= 3 | [![CocoaPods](https://img.shields.io/cocoapods/v/MMPulseView.svg)]() 4 | [![CocoaPods](https://img.shields.io/cocoapods/p/MMPulseView.svg)]() 5 | [![CocoaPods](https://img.shields.io/cocoapods/l/MMPulseView.svg)]() 6 | 7 | A simple view to show circle pulse repeatly. 8 | 9 | ![demo](https://github.com/adad184/MMPulseView/blob/master/demo.gif) 10 | 11 | Installation 12 | ============ 13 | 14 | The preferred way of installation is via [CocoaPods](http://cocoapods.org). Just add 15 | 16 | ```ruby 17 | pod 'MMPulseView' 18 | ``` 19 | 20 | and run `pod install`. It will install the most recent version of MMPulseView. 21 | 22 | If you would like to use the latest code of MMPulseView use: 23 | 24 | ```ruby 25 | pod 'MMPulseView', :head 26 | ``` 27 | 28 | Usage 29 | =============== 30 | ```objc 31 | pulseView.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]; 32 | pulseView.colors = @[(__bridge id)[UIColor whiteColor].CGColor, 33 | (__bridge id)[UIColor blackColor].CGColor, 34 | (__bridge id)[UIColor whiteColor].CGColor]; 35 | pulseView.locations = @[@(0.3),@(0.5),@(0.7)]; 36 | pulseView.startPoint = CGPointMake(0, 0.5); 37 | pulseView.endPoint = CGPointMake(1, 0.5); 38 | 39 | pulseView.minRadius = 0; 40 | pulseView.maxRadius = 100; 41 | 42 | pulseView.duration = 3; 43 | pulseView.count = 6; 44 | pulseView.lineWidth = 3.0f; 45 | 46 | [pulseView startAnimation]; 47 | ``` 48 | 49 | Changelog 50 | =============== 51 | v1.0 first version 52 | -------------------------------------------------------------------------------- /demo.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/adad184/MMPulseView/17a9616616298aef33d391a4d28a537a71f1cffe/demo.gif --------------------------------------------------------------------------------