├── JBCoundownLabel.podspec ├── JBCoundownLabelSampleProject.xcodeproj ├── project.pbxproj ├── project.xcworkspace │ ├── contents.xcworkspacedata │ ├── xcshareddata │ │ └── JBCoundownLabelSampleProject.xccheckout │ └── xcuserdata │ │ └── jberlana.xcuserdatad │ │ └── WorkspaceSettings.xcsettings └── xcuserdata │ └── jberlana.xcuserdatad │ ├── xcdebugger │ └── Breakpoints_v2.xcbkptlist │ └── xcschemes │ ├── JBCoundownLabelSampleProject.xcscheme │ └── xcschememanagement.plist ├── JBCoundownLabelSampleProject ├── AppDelegate.h ├── AppDelegate.m ├── Base.lproj │ └── Main.storyboard ├── Images.xcassets │ ├── AppIcon.appiconset │ │ └── Contents.json │ └── LaunchImage.launchimage │ │ └── Contents.json ├── JBCoundownLabelSampleProject-Info.plist ├── JBCoundownLabelSampleProject-Prefix.pch ├── JBCountdownLabel.h ├── JBCountdownLabel.m ├── ViewController.h ├── ViewController.m ├── en.lproj │ └── InfoPlist.strings └── main.m ├── JBCoundownLabelSampleProjectTests ├── JBCoundownLabelSampleProjectTests-Info.plist ├── JBCoundownLabelSampleProjectTests.m └── en.lproj │ └── InfoPlist.strings ├── LICENSE.txt ├── README.md └── demo.gif /JBCoundownLabel.podspec: -------------------------------------------------------------------------------- 1 | Pod::Spec.new do |s| 2 | 3 | s.name = "JBCoundownLabel" 4 | s.version = "0.0.2" 5 | s.summary = "A UILabel subclass that displays a countdown" 6 | s.platform = :ios 7 | s.ios.deployment_target = "6.0" 8 | 9 | s.description = <<-DESC 10 | JBCountdownLabel is UILabel subclass that displays a countdown with a defined amount of seconds. So you can customise the label just like a native `UILabel` and add some cool actions 11 | DESC 12 | 13 | s.homepage = "https://github.com/jberlana/JBCoundownLabel" 14 | s.screenshots = "https://raw.githubusercontent.com/jberlana/JBCoundownLabel/master/demo.gif" 15 | s.license = "MIT" 16 | s.author = { "Javier Berlana" => "jberlana@gmail.com" } 17 | s.social_media_url = "http://twitter.com/jberlana" 18 | s.source = { :git => "https://github.com/jberlana/JBCoundownLabel.git", :tag => "0.0.2" } 19 | 20 | s.source_files = "JBCoundownLabelSampleProject/JBCountdownLabel.h", "JBCoundownLabelSampleProject/JBCountdownLabel.m" 21 | 22 | s.requires_arc = true 23 | 24 | end 25 | -------------------------------------------------------------------------------- /JBCoundownLabelSampleProject.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 4262F21D1951B8D000E57E0B /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4262F21C1951B8D000E57E0B /* Foundation.framework */; }; 11 | 4262F21F1951B8D000E57E0B /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4262F21E1951B8D000E57E0B /* CoreGraphics.framework */; }; 12 | 4262F2211951B8D000E57E0B /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4262F2201951B8D000E57E0B /* UIKit.framework */; }; 13 | 4262F2271951B8D000E57E0B /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 4262F2251951B8D000E57E0B /* InfoPlist.strings */; }; 14 | 4262F2291951B8D000E57E0B /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 4262F2281951B8D000E57E0B /* main.m */; }; 15 | 4262F22D1951B8D000E57E0B /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 4262F22C1951B8D000E57E0B /* AppDelegate.m */; }; 16 | 4262F2301951B8D000E57E0B /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 4262F22E1951B8D000E57E0B /* Main.storyboard */; }; 17 | 4262F2331951B8D000E57E0B /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 4262F2321951B8D000E57E0B /* ViewController.m */; }; 18 | 4262F2351951B8D000E57E0B /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 4262F2341951B8D000E57E0B /* Images.xcassets */; }; 19 | 4262F23C1951B8D000E57E0B /* XCTest.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4262F23B1951B8D000E57E0B /* XCTest.framework */; }; 20 | 4262F23D1951B8D000E57E0B /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4262F21C1951B8D000E57E0B /* Foundation.framework */; }; 21 | 4262F23E1951B8D000E57E0B /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4262F2201951B8D000E57E0B /* UIKit.framework */; }; 22 | 4262F2461951B8D000E57E0B /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 4262F2441951B8D000E57E0B /* InfoPlist.strings */; }; 23 | 4262F2481951B8D000E57E0B /* JBCoundownLabelSampleProjectTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 4262F2471951B8D000E57E0B /* JBCoundownLabelSampleProjectTests.m */; }; 24 | 4262F2541951B92F00E57E0B /* JBCountdownLabel.m in Sources */ = {isa = PBXBuildFile; fileRef = 4262F2531951B92F00E57E0B /* JBCountdownLabel.m */; }; 25 | /* End PBXBuildFile section */ 26 | 27 | /* Begin PBXContainerItemProxy section */ 28 | 4262F23F1951B8D000E57E0B /* PBXContainerItemProxy */ = { 29 | isa = PBXContainerItemProxy; 30 | containerPortal = 4262F2111951B8D000E57E0B /* Project object */; 31 | proxyType = 1; 32 | remoteGlobalIDString = 4262F2181951B8D000E57E0B; 33 | remoteInfo = JBCoundownLabelSampleProject; 34 | }; 35 | /* End PBXContainerItemProxy section */ 36 | 37 | /* Begin PBXFileReference section */ 38 | 4262F2191951B8D000E57E0B /* JBCoundownLabelSampleProject.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = JBCoundownLabelSampleProject.app; sourceTree = BUILT_PRODUCTS_DIR; }; 39 | 4262F21C1951B8D000E57E0B /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; }; 40 | 4262F21E1951B8D000E57E0B /* CoreGraphics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreGraphics.framework; path = System/Library/Frameworks/CoreGraphics.framework; sourceTree = SDKROOT; }; 41 | 4262F2201951B8D000E57E0B /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; }; 42 | 4262F2241951B8D000E57E0B /* JBCoundownLabelSampleProject-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "JBCoundownLabelSampleProject-Info.plist"; sourceTree = ""; }; 43 | 4262F2261951B8D000E57E0B /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = ""; }; 44 | 4262F2281951B8D000E57E0B /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; 45 | 4262F22A1951B8D000E57E0B /* JBCoundownLabelSampleProject-Prefix.pch */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "JBCoundownLabelSampleProject-Prefix.pch"; sourceTree = ""; }; 46 | 4262F22B1951B8D000E57E0B /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; 47 | 4262F22C1951B8D000E57E0B /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; }; 48 | 4262F22F1951B8D000E57E0B /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 49 | 4262F2311951B8D000E57E0B /* ViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ViewController.h; sourceTree = ""; }; 50 | 4262F2321951B8D000E57E0B /* ViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ViewController.m; sourceTree = ""; }; 51 | 4262F2341951B8D000E57E0B /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Images.xcassets; sourceTree = ""; }; 52 | 4262F23A1951B8D000E57E0B /* JBCoundownLabelSampleProjectTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = JBCoundownLabelSampleProjectTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 53 | 4262F23B1951B8D000E57E0B /* XCTest.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = XCTest.framework; path = Library/Frameworks/XCTest.framework; sourceTree = DEVELOPER_DIR; }; 54 | 4262F2431951B8D000E57E0B /* JBCoundownLabelSampleProjectTests-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "JBCoundownLabelSampleProjectTests-Info.plist"; sourceTree = ""; }; 55 | 4262F2451951B8D000E57E0B /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = ""; }; 56 | 4262F2471951B8D000E57E0B /* JBCoundownLabelSampleProjectTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = JBCoundownLabelSampleProjectTests.m; sourceTree = ""; }; 57 | 4262F2521951B92F00E57E0B /* JBCountdownLabel.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JBCountdownLabel.h; sourceTree = ""; }; 58 | 4262F2531951B92F00E57E0B /* JBCountdownLabel.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = JBCountdownLabel.m; sourceTree = ""; }; 59 | /* End PBXFileReference section */ 60 | 61 | /* Begin PBXFrameworksBuildPhase section */ 62 | 4262F2161951B8D000E57E0B /* Frameworks */ = { 63 | isa = PBXFrameworksBuildPhase; 64 | buildActionMask = 2147483647; 65 | files = ( 66 | 4262F21F1951B8D000E57E0B /* CoreGraphics.framework in Frameworks */, 67 | 4262F2211951B8D000E57E0B /* UIKit.framework in Frameworks */, 68 | 4262F21D1951B8D000E57E0B /* Foundation.framework in Frameworks */, 69 | ); 70 | runOnlyForDeploymentPostprocessing = 0; 71 | }; 72 | 4262F2371951B8D000E57E0B /* Frameworks */ = { 73 | isa = PBXFrameworksBuildPhase; 74 | buildActionMask = 2147483647; 75 | files = ( 76 | 4262F23C1951B8D000E57E0B /* XCTest.framework in Frameworks */, 77 | 4262F23E1951B8D000E57E0B /* UIKit.framework in Frameworks */, 78 | 4262F23D1951B8D000E57E0B /* Foundation.framework in Frameworks */, 79 | ); 80 | runOnlyForDeploymentPostprocessing = 0; 81 | }; 82 | /* End PBXFrameworksBuildPhase section */ 83 | 84 | /* Begin PBXGroup section */ 85 | 4262F2101951B8D000E57E0B = { 86 | isa = PBXGroup; 87 | children = ( 88 | 4262F2221951B8D000E57E0B /* JBCoundownLabelSampleProject */, 89 | 4262F2411951B8D000E57E0B /* JBCoundownLabelSampleProjectTests */, 90 | 4262F21B1951B8D000E57E0B /* Frameworks */, 91 | 4262F21A1951B8D000E57E0B /* Products */, 92 | ); 93 | sourceTree = ""; 94 | }; 95 | 4262F21A1951B8D000E57E0B /* Products */ = { 96 | isa = PBXGroup; 97 | children = ( 98 | 4262F2191951B8D000E57E0B /* JBCoundownLabelSampleProject.app */, 99 | 4262F23A1951B8D000E57E0B /* JBCoundownLabelSampleProjectTests.xctest */, 100 | ); 101 | name = Products; 102 | sourceTree = ""; 103 | }; 104 | 4262F21B1951B8D000E57E0B /* Frameworks */ = { 105 | isa = PBXGroup; 106 | children = ( 107 | 4262F21C1951B8D000E57E0B /* Foundation.framework */, 108 | 4262F21E1951B8D000E57E0B /* CoreGraphics.framework */, 109 | 4262F2201951B8D000E57E0B /* UIKit.framework */, 110 | 4262F23B1951B8D000E57E0B /* XCTest.framework */, 111 | ); 112 | name = Frameworks; 113 | sourceTree = ""; 114 | }; 115 | 4262F2221951B8D000E57E0B /* JBCoundownLabelSampleProject */ = { 116 | isa = PBXGroup; 117 | children = ( 118 | 4262F2511951B8E100E57E0B /* JBCountdownLabel */, 119 | 4262F22E1951B8D000E57E0B /* Main.storyboard */, 120 | 4262F22B1951B8D000E57E0B /* AppDelegate.h */, 121 | 4262F22C1951B8D000E57E0B /* AppDelegate.m */, 122 | 4262F2311951B8D000E57E0B /* ViewController.h */, 123 | 4262F2321951B8D000E57E0B /* ViewController.m */, 124 | 4262F2341951B8D000E57E0B /* Images.xcassets */, 125 | 4262F2231951B8D000E57E0B /* Supporting Files */, 126 | ); 127 | path = JBCoundownLabelSampleProject; 128 | sourceTree = ""; 129 | }; 130 | 4262F2231951B8D000E57E0B /* Supporting Files */ = { 131 | isa = PBXGroup; 132 | children = ( 133 | 4262F2241951B8D000E57E0B /* JBCoundownLabelSampleProject-Info.plist */, 134 | 4262F2251951B8D000E57E0B /* InfoPlist.strings */, 135 | 4262F2281951B8D000E57E0B /* main.m */, 136 | 4262F22A1951B8D000E57E0B /* JBCoundownLabelSampleProject-Prefix.pch */, 137 | ); 138 | name = "Supporting Files"; 139 | sourceTree = ""; 140 | }; 141 | 4262F2411951B8D000E57E0B /* JBCoundownLabelSampleProjectTests */ = { 142 | isa = PBXGroup; 143 | children = ( 144 | 4262F2471951B8D000E57E0B /* JBCoundownLabelSampleProjectTests.m */, 145 | 4262F2421951B8D000E57E0B /* Supporting Files */, 146 | ); 147 | path = JBCoundownLabelSampleProjectTests; 148 | sourceTree = ""; 149 | }; 150 | 4262F2421951B8D000E57E0B /* Supporting Files */ = { 151 | isa = PBXGroup; 152 | children = ( 153 | 4262F2431951B8D000E57E0B /* JBCoundownLabelSampleProjectTests-Info.plist */, 154 | 4262F2441951B8D000E57E0B /* InfoPlist.strings */, 155 | ); 156 | name = "Supporting Files"; 157 | sourceTree = ""; 158 | }; 159 | 4262F2511951B8E100E57E0B /* JBCountdownLabel */ = { 160 | isa = PBXGroup; 161 | children = ( 162 | 4262F2521951B92F00E57E0B /* JBCountdownLabel.h */, 163 | 4262F2531951B92F00E57E0B /* JBCountdownLabel.m */, 164 | ); 165 | name = JBCountdownLabel; 166 | sourceTree = ""; 167 | }; 168 | /* End PBXGroup section */ 169 | 170 | /* Begin PBXNativeTarget section */ 171 | 4262F2181951B8D000E57E0B /* JBCoundownLabelSampleProject */ = { 172 | isa = PBXNativeTarget; 173 | buildConfigurationList = 4262F24B1951B8D000E57E0B /* Build configuration list for PBXNativeTarget "JBCoundownLabelSampleProject" */; 174 | buildPhases = ( 175 | 4262F2151951B8D000E57E0B /* Sources */, 176 | 4262F2161951B8D000E57E0B /* Frameworks */, 177 | 4262F2171951B8D000E57E0B /* Resources */, 178 | ); 179 | buildRules = ( 180 | ); 181 | dependencies = ( 182 | ); 183 | name = JBCoundownLabelSampleProject; 184 | productName = JBCoundownLabelSampleProject; 185 | productReference = 4262F2191951B8D000E57E0B /* JBCoundownLabelSampleProject.app */; 186 | productType = "com.apple.product-type.application"; 187 | }; 188 | 4262F2391951B8D000E57E0B /* JBCoundownLabelSampleProjectTests */ = { 189 | isa = PBXNativeTarget; 190 | buildConfigurationList = 4262F24E1951B8D000E57E0B /* Build configuration list for PBXNativeTarget "JBCoundownLabelSampleProjectTests" */; 191 | buildPhases = ( 192 | 4262F2361951B8D000E57E0B /* Sources */, 193 | 4262F2371951B8D000E57E0B /* Frameworks */, 194 | 4262F2381951B8D000E57E0B /* Resources */, 195 | ); 196 | buildRules = ( 197 | ); 198 | dependencies = ( 199 | 4262F2401951B8D000E57E0B /* PBXTargetDependency */, 200 | ); 201 | name = JBCoundownLabelSampleProjectTests; 202 | productName = JBCoundownLabelSampleProjectTests; 203 | productReference = 4262F23A1951B8D000E57E0B /* JBCoundownLabelSampleProjectTests.xctest */; 204 | productType = "com.apple.product-type.bundle.unit-test"; 205 | }; 206 | /* End PBXNativeTarget section */ 207 | 208 | /* Begin PBXProject section */ 209 | 4262F2111951B8D000E57E0B /* Project object */ = { 210 | isa = PBXProject; 211 | attributes = { 212 | LastUpgradeCheck = 0510; 213 | ORGANIZATIONNAME = "Javier Berlana"; 214 | TargetAttributes = { 215 | 4262F2391951B8D000E57E0B = { 216 | TestTargetID = 4262F2181951B8D000E57E0B; 217 | }; 218 | }; 219 | }; 220 | buildConfigurationList = 4262F2141951B8D000E57E0B /* Build configuration list for PBXProject "JBCoundownLabelSampleProject" */; 221 | compatibilityVersion = "Xcode 3.2"; 222 | developmentRegion = English; 223 | hasScannedForEncodings = 0; 224 | knownRegions = ( 225 | en, 226 | Base, 227 | ); 228 | mainGroup = 4262F2101951B8D000E57E0B; 229 | productRefGroup = 4262F21A1951B8D000E57E0B /* Products */; 230 | projectDirPath = ""; 231 | projectRoot = ""; 232 | targets = ( 233 | 4262F2181951B8D000E57E0B /* JBCoundownLabelSampleProject */, 234 | 4262F2391951B8D000E57E0B /* JBCoundownLabelSampleProjectTests */, 235 | ); 236 | }; 237 | /* End PBXProject section */ 238 | 239 | /* Begin PBXResourcesBuildPhase section */ 240 | 4262F2171951B8D000E57E0B /* Resources */ = { 241 | isa = PBXResourcesBuildPhase; 242 | buildActionMask = 2147483647; 243 | files = ( 244 | 4262F2351951B8D000E57E0B /* Images.xcassets in Resources */, 245 | 4262F2271951B8D000E57E0B /* InfoPlist.strings in Resources */, 246 | 4262F2301951B8D000E57E0B /* Main.storyboard in Resources */, 247 | ); 248 | runOnlyForDeploymentPostprocessing = 0; 249 | }; 250 | 4262F2381951B8D000E57E0B /* Resources */ = { 251 | isa = PBXResourcesBuildPhase; 252 | buildActionMask = 2147483647; 253 | files = ( 254 | 4262F2461951B8D000E57E0B /* InfoPlist.strings in Resources */, 255 | ); 256 | runOnlyForDeploymentPostprocessing = 0; 257 | }; 258 | /* End PBXResourcesBuildPhase section */ 259 | 260 | /* Begin PBXSourcesBuildPhase section */ 261 | 4262F2151951B8D000E57E0B /* Sources */ = { 262 | isa = PBXSourcesBuildPhase; 263 | buildActionMask = 2147483647; 264 | files = ( 265 | 4262F2541951B92F00E57E0B /* JBCountdownLabel.m in Sources */, 266 | 4262F2331951B8D000E57E0B /* ViewController.m in Sources */, 267 | 4262F22D1951B8D000E57E0B /* AppDelegate.m in Sources */, 268 | 4262F2291951B8D000E57E0B /* main.m in Sources */, 269 | ); 270 | runOnlyForDeploymentPostprocessing = 0; 271 | }; 272 | 4262F2361951B8D000E57E0B /* Sources */ = { 273 | isa = PBXSourcesBuildPhase; 274 | buildActionMask = 2147483647; 275 | files = ( 276 | 4262F2481951B8D000E57E0B /* JBCoundownLabelSampleProjectTests.m in Sources */, 277 | ); 278 | runOnlyForDeploymentPostprocessing = 0; 279 | }; 280 | /* End PBXSourcesBuildPhase section */ 281 | 282 | /* Begin PBXTargetDependency section */ 283 | 4262F2401951B8D000E57E0B /* PBXTargetDependency */ = { 284 | isa = PBXTargetDependency; 285 | target = 4262F2181951B8D000E57E0B /* JBCoundownLabelSampleProject */; 286 | targetProxy = 4262F23F1951B8D000E57E0B /* PBXContainerItemProxy */; 287 | }; 288 | /* End PBXTargetDependency section */ 289 | 290 | /* Begin PBXVariantGroup section */ 291 | 4262F2251951B8D000E57E0B /* InfoPlist.strings */ = { 292 | isa = PBXVariantGroup; 293 | children = ( 294 | 4262F2261951B8D000E57E0B /* en */, 295 | ); 296 | name = InfoPlist.strings; 297 | sourceTree = ""; 298 | }; 299 | 4262F22E1951B8D000E57E0B /* Main.storyboard */ = { 300 | isa = PBXVariantGroup; 301 | children = ( 302 | 4262F22F1951B8D000E57E0B /* Base */, 303 | ); 304 | name = Main.storyboard; 305 | sourceTree = ""; 306 | }; 307 | 4262F2441951B8D000E57E0B /* InfoPlist.strings */ = { 308 | isa = PBXVariantGroup; 309 | children = ( 310 | 4262F2451951B8D000E57E0B /* en */, 311 | ); 312 | name = InfoPlist.strings; 313 | sourceTree = ""; 314 | }; 315 | /* End PBXVariantGroup section */ 316 | 317 | /* Begin XCBuildConfiguration section */ 318 | 4262F2491951B8D000E57E0B /* Debug */ = { 319 | isa = XCBuildConfiguration; 320 | buildSettings = { 321 | ALWAYS_SEARCH_USER_PATHS = NO; 322 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 323 | CLANG_CXX_LIBRARY = "libc++"; 324 | CLANG_ENABLE_MODULES = YES; 325 | CLANG_ENABLE_OBJC_ARC = YES; 326 | CLANG_WARN_BOOL_CONVERSION = YES; 327 | CLANG_WARN_CONSTANT_CONVERSION = YES; 328 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 329 | CLANG_WARN_EMPTY_BODY = YES; 330 | CLANG_WARN_ENUM_CONVERSION = YES; 331 | CLANG_WARN_INT_CONVERSION = YES; 332 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 333 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 334 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 335 | COPY_PHASE_STRIP = NO; 336 | GCC_C_LANGUAGE_STANDARD = gnu99; 337 | GCC_DYNAMIC_NO_PIC = NO; 338 | GCC_OPTIMIZATION_LEVEL = 0; 339 | GCC_PREPROCESSOR_DEFINITIONS = ( 340 | "DEBUG=1", 341 | "$(inherited)", 342 | ); 343 | GCC_SYMBOLS_PRIVATE_EXTERN = NO; 344 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 345 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 346 | GCC_WARN_UNDECLARED_SELECTOR = YES; 347 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 348 | GCC_WARN_UNUSED_FUNCTION = YES; 349 | GCC_WARN_UNUSED_VARIABLE = YES; 350 | IPHONEOS_DEPLOYMENT_TARGET = 7.1; 351 | ONLY_ACTIVE_ARCH = YES; 352 | SDKROOT = iphoneos; 353 | }; 354 | name = Debug; 355 | }; 356 | 4262F24A1951B8D000E57E0B /* Release */ = { 357 | isa = XCBuildConfiguration; 358 | buildSettings = { 359 | ALWAYS_SEARCH_USER_PATHS = NO; 360 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 361 | CLANG_CXX_LIBRARY = "libc++"; 362 | CLANG_ENABLE_MODULES = YES; 363 | CLANG_ENABLE_OBJC_ARC = YES; 364 | CLANG_WARN_BOOL_CONVERSION = YES; 365 | CLANG_WARN_CONSTANT_CONVERSION = YES; 366 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 367 | CLANG_WARN_EMPTY_BODY = YES; 368 | CLANG_WARN_ENUM_CONVERSION = YES; 369 | CLANG_WARN_INT_CONVERSION = YES; 370 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 371 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 372 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 373 | COPY_PHASE_STRIP = YES; 374 | ENABLE_NS_ASSERTIONS = NO; 375 | GCC_C_LANGUAGE_STANDARD = gnu99; 376 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 377 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 378 | GCC_WARN_UNDECLARED_SELECTOR = YES; 379 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 380 | GCC_WARN_UNUSED_FUNCTION = YES; 381 | GCC_WARN_UNUSED_VARIABLE = YES; 382 | IPHONEOS_DEPLOYMENT_TARGET = 7.1; 383 | SDKROOT = iphoneos; 384 | VALIDATE_PRODUCT = YES; 385 | }; 386 | name = Release; 387 | }; 388 | 4262F24C1951B8D000E57E0B /* Debug */ = { 389 | isa = XCBuildConfiguration; 390 | buildSettings = { 391 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 392 | ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage; 393 | GCC_PRECOMPILE_PREFIX_HEADER = YES; 394 | GCC_PREFIX_HEADER = "JBCoundownLabelSampleProject/JBCoundownLabelSampleProject-Prefix.pch"; 395 | INFOPLIST_FILE = "JBCoundownLabelSampleProject/JBCoundownLabelSampleProject-Info.plist"; 396 | PRODUCT_NAME = "$(TARGET_NAME)"; 397 | WRAPPER_EXTENSION = app; 398 | }; 399 | name = Debug; 400 | }; 401 | 4262F24D1951B8D000E57E0B /* Release */ = { 402 | isa = XCBuildConfiguration; 403 | buildSettings = { 404 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 405 | ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage; 406 | GCC_PRECOMPILE_PREFIX_HEADER = YES; 407 | GCC_PREFIX_HEADER = "JBCoundownLabelSampleProject/JBCoundownLabelSampleProject-Prefix.pch"; 408 | INFOPLIST_FILE = "JBCoundownLabelSampleProject/JBCoundownLabelSampleProject-Info.plist"; 409 | PRODUCT_NAME = "$(TARGET_NAME)"; 410 | WRAPPER_EXTENSION = app; 411 | }; 412 | name = Release; 413 | }; 414 | 4262F24F1951B8D000E57E0B /* Debug */ = { 415 | isa = XCBuildConfiguration; 416 | buildSettings = { 417 | BUNDLE_LOADER = "$(BUILT_PRODUCTS_DIR)/JBCoundownLabelSampleProject.app/JBCoundownLabelSampleProject"; 418 | FRAMEWORK_SEARCH_PATHS = ( 419 | "$(SDKROOT)/Developer/Library/Frameworks", 420 | "$(inherited)", 421 | "$(DEVELOPER_FRAMEWORKS_DIR)", 422 | ); 423 | GCC_PRECOMPILE_PREFIX_HEADER = YES; 424 | GCC_PREFIX_HEADER = "JBCoundownLabelSampleProject/JBCoundownLabelSampleProject-Prefix.pch"; 425 | GCC_PREPROCESSOR_DEFINITIONS = ( 426 | "DEBUG=1", 427 | "$(inherited)", 428 | ); 429 | INFOPLIST_FILE = "JBCoundownLabelSampleProjectTests/JBCoundownLabelSampleProjectTests-Info.plist"; 430 | PRODUCT_NAME = "$(TARGET_NAME)"; 431 | TEST_HOST = "$(BUNDLE_LOADER)"; 432 | WRAPPER_EXTENSION = xctest; 433 | }; 434 | name = Debug; 435 | }; 436 | 4262F2501951B8D000E57E0B /* Release */ = { 437 | isa = XCBuildConfiguration; 438 | buildSettings = { 439 | BUNDLE_LOADER = "$(BUILT_PRODUCTS_DIR)/JBCoundownLabelSampleProject.app/JBCoundownLabelSampleProject"; 440 | FRAMEWORK_SEARCH_PATHS = ( 441 | "$(SDKROOT)/Developer/Library/Frameworks", 442 | "$(inherited)", 443 | "$(DEVELOPER_FRAMEWORKS_DIR)", 444 | ); 445 | GCC_PRECOMPILE_PREFIX_HEADER = YES; 446 | GCC_PREFIX_HEADER = "JBCoundownLabelSampleProject/JBCoundownLabelSampleProject-Prefix.pch"; 447 | INFOPLIST_FILE = "JBCoundownLabelSampleProjectTests/JBCoundownLabelSampleProjectTests-Info.plist"; 448 | PRODUCT_NAME = "$(TARGET_NAME)"; 449 | TEST_HOST = "$(BUNDLE_LOADER)"; 450 | WRAPPER_EXTENSION = xctest; 451 | }; 452 | name = Release; 453 | }; 454 | /* End XCBuildConfiguration section */ 455 | 456 | /* Begin XCConfigurationList section */ 457 | 4262F2141951B8D000E57E0B /* Build configuration list for PBXProject "JBCoundownLabelSampleProject" */ = { 458 | isa = XCConfigurationList; 459 | buildConfigurations = ( 460 | 4262F2491951B8D000E57E0B /* Debug */, 461 | 4262F24A1951B8D000E57E0B /* Release */, 462 | ); 463 | defaultConfigurationIsVisible = 0; 464 | defaultConfigurationName = Release; 465 | }; 466 | 4262F24B1951B8D000E57E0B /* Build configuration list for PBXNativeTarget "JBCoundownLabelSampleProject" */ = { 467 | isa = XCConfigurationList; 468 | buildConfigurations = ( 469 | 4262F24C1951B8D000E57E0B /* Debug */, 470 | 4262F24D1951B8D000E57E0B /* Release */, 471 | ); 472 | defaultConfigurationIsVisible = 0; 473 | }; 474 | 4262F24E1951B8D000E57E0B /* Build configuration list for PBXNativeTarget "JBCoundownLabelSampleProjectTests" */ = { 475 | isa = XCConfigurationList; 476 | buildConfigurations = ( 477 | 4262F24F1951B8D000E57E0B /* Debug */, 478 | 4262F2501951B8D000E57E0B /* Release */, 479 | ); 480 | defaultConfigurationIsVisible = 0; 481 | }; 482 | /* End XCConfigurationList section */ 483 | }; 484 | rootObject = 4262F2111951B8D000E57E0B /* Project object */; 485 | } 486 | -------------------------------------------------------------------------------- /JBCoundownLabelSampleProject.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /JBCoundownLabelSampleProject.xcodeproj/project.xcworkspace/xcshareddata/JBCoundownLabelSampleProject.xccheckout: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDESourceControlProjectFavoriteDictionaryKey 6 | 7 | IDESourceControlProjectIdentifier 8 | A1130042-D080-4E7E-85DF-AE7A0AC3189A 9 | IDESourceControlProjectName 10 | JBCoundownLabelSampleProject 11 | IDESourceControlProjectOriginsDictionary 12 | 13 | 8EA7BBA8-64A7-45E7-A3B7-496C0A1E261F 14 | https://github.com/jberlana/JBCoundownLabel.git 15 | 16 | IDESourceControlProjectPath 17 | JBCoundownLabelSampleProject.xcodeproj/project.xcworkspace 18 | IDESourceControlProjectRelativeInstallPathDictionary 19 | 20 | 8EA7BBA8-64A7-45E7-A3B7-496C0A1E261F 21 | ../.. 22 | 23 | IDESourceControlProjectURL 24 | https://github.com/jberlana/JBCoundownLabel.git 25 | IDESourceControlProjectVersion 26 | 110 27 | IDESourceControlProjectWCCIdentifier 28 | 8EA7BBA8-64A7-45E7-A3B7-496C0A1E261F 29 | IDESourceControlProjectWCConfigurations 30 | 31 | 32 | IDESourceControlRepositoryExtensionIdentifierKey 33 | public.vcs.git 34 | IDESourceControlWCCIdentifierKey 35 | 8EA7BBA8-64A7-45E7-A3B7-496C0A1E261F 36 | IDESourceControlWCCName 37 | JBCoundownLabel 38 | 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /JBCoundownLabelSampleProject.xcodeproj/project.xcworkspace/xcuserdata/jberlana.xcuserdatad/WorkspaceSettings.xcsettings: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | HasAskedToTakeAutomaticSnapshotBeforeSignificantChanges 6 | 7 | SnapshotAutomaticallyBeforeSignificantChanges 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /JBCoundownLabelSampleProject.xcodeproj/xcuserdata/jberlana.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | -------------------------------------------------------------------------------- /JBCoundownLabelSampleProject.xcodeproj/xcuserdata/jberlana.xcuserdatad/xcschemes/JBCoundownLabelSampleProject.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 33 | 39 | 40 | 41 | 42 | 43 | 49 | 50 | 51 | 52 | 61 | 62 | 68 | 69 | 70 | 71 | 72 | 73 | 79 | 80 | 86 | 87 | 88 | 89 | 91 | 92 | 95 | 96 | 97 | -------------------------------------------------------------------------------- /JBCoundownLabelSampleProject.xcodeproj/xcuserdata/jberlana.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | JBCoundownLabelSampleProject.xcscheme 8 | 9 | orderHint 10 | 0 11 | 12 | 13 | SuppressBuildableAutocreation 14 | 15 | 4262F2181951B8D000E57E0B 16 | 17 | primary 18 | 19 | 20 | 4262F2391951B8D000E57E0B 21 | 22 | primary 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /JBCoundownLabelSampleProject/AppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.h 3 | // JBCoundownLabelSampleProject 4 | // 5 | // Created by Javier Berlana on 18/06/14. 6 | // Copyright (c) 2014 Javier Berlana. All rights reserved. 7 | // 8 | // 9 | 10 | #import 11 | 12 | @interface AppDelegate : UIResponder 13 | 14 | @property (strong, nonatomic) UIWindow *window; 15 | 16 | @end 17 | -------------------------------------------------------------------------------- /JBCoundownLabelSampleProject/AppDelegate.m: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.m 3 | // JBCoundownLabelSampleProject 4 | // 5 | // Created by Javier Berlana on 18/06/14. 6 | // Copyright (c) 2014 Javier Berlana. 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 | -------------------------------------------------------------------------------- /JBCoundownLabelSampleProject/Base.lproj/Main.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 29 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | -------------------------------------------------------------------------------- /JBCoundownLabelSampleProject/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 | } -------------------------------------------------------------------------------- /JBCoundownLabelSampleProject/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 | } -------------------------------------------------------------------------------- /JBCoundownLabelSampleProject/JBCoundownLabelSampleProject-Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleDisplayName 8 | ${PRODUCT_NAME} 9 | CFBundleExecutable 10 | ${EXECUTABLE_NAME} 11 | CFBundleIdentifier 12 | meets.${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 | -------------------------------------------------------------------------------- /JBCoundownLabelSampleProject/JBCoundownLabelSampleProject-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 | -------------------------------------------------------------------------------- /JBCoundownLabelSampleProject/JBCountdownLabel.h: -------------------------------------------------------------------------------- 1 | // 2 | // JBCountdownLabel.h 3 | // Meets 4 | // 5 | // Created by Javier Berlana on 18/06/14. 6 | // Copyright (c) 2014 Meetsapp. All rights reserved. 7 | // 8 | // Permission is hereby granted, free of charge, to any person obtaining a copy 9 | // of this software and associated documentation files (the "Software"), to deal 10 | // in the Software without restriction, including without limitation the rights 11 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | // copies of the Software, and to permit persons to whom the Software is 13 | // furnished to do so, subject to the following conditions: 14 | // 15 | // The above copyright notice and this permission notice shall be included in 16 | // all copies or substantial portions of the Software. 17 | // 18 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | // THE SOFTWARE. 25 | // 26 | 27 | #import 28 | 29 | @class JBCountdownLabel; 30 | 31 | /** 32 | The `CountdownDelegate` protocol is adopted by a viewcontroller that ads a countdown label as a subview in order to get notified when the countdown ended. 33 | */ 34 | @protocol CountdownDelegate 35 | 36 | @optional 37 | /** 38 | Get called when the countdown ends. 39 | @param countdown The countdown that has ended. 40 | @since 0.0.1 41 | */ 42 | - (void)countdownFinnishIn:(JBCountdownLabel *)countdown; 43 | 44 | @end 45 | 46 | 47 | /** 48 | `JBCountdownLabel` is a subclass of `UILabel` that displays a countdown with a defined amount of seconds. 49 | */ 50 | 51 | @interface JBCountdownLabel : UILabel 52 | 53 | /** 54 | Initializes and returns a newly allocated UILabel object with a countdown configured with the specified number of seconds. 55 | @param frame The fram of the UILabel. 56 | @param string The format string text of the UILabel, `%@` to define where to place the countdown. 57 | @param seconds The number of seconds of the countdown. 58 | @param delegate The delegate that will receive callbacks when the countdown ends. 59 | @since 0.0.1 60 | */ 61 | - (instancetype)initWithFrame:(CGRect)frame format:(NSString *)string time:(int)seconds delegate:(id )delegate; 62 | 63 | ///---------------------------------- 64 | /// @name Manage countdown 65 | ///---------------------------------- 66 | 67 | /** 68 | Restart the countdown setting the countdown to the initial amount of seconds. 69 | @since 0.0.1 70 | */ 71 | - (void)restartCountdown; 72 | 73 | /** 74 | Cancel the countdown setting the countdown to 0. 75 | @since 0.0.1 76 | */ 77 | - (void)cancelCountdown; 78 | 79 | /** 80 | Set a new amount of seconds to the current countdown and restarts it. 81 | @param seconds The new amount of seconds to define on the countdown. 82 | @since 0.0.1 83 | */ 84 | - (void)setTime:(int)seconds; 85 | 86 | @end 87 | -------------------------------------------------------------------------------- /JBCoundownLabelSampleProject/JBCountdownLabel.m: -------------------------------------------------------------------------------- 1 | // 2 | // JBCountdownLabel.m 3 | // Meets 4 | // 5 | // Created by Javier Berlana on 18/06/14. 6 | // Copyright (c) 2014 Meetsapp. All rights reserved. 7 | // 8 | // Permission is hereby granted, free of charge, to any person obtaining a copy 9 | // of this software and associated documentation files (the "Software"), to deal 10 | // in the Software without restriction, including without limitation the rights 11 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | // copies of the Software, and to permit persons to whom the Software is 13 | // furnished to do so, subject to the following conditions: 14 | // 15 | // The above copyright notice and this permission notice shall be included in 16 | // all copies or substantial portions of the Software. 17 | // 18 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | // THE SOFTWARE. 25 | // 26 | 27 | #import "JBCountdownLabel.h" 28 | 29 | @interface JBCountdownLabel() 30 | 31 | @property (nonatomic, weak) id delegate; 32 | @property (nonatomic, strong) NSString *stringFormat; 33 | @property (nonatomic, strong) NSDate *expirationDate; 34 | @property (nonatomic, strong) NSTimer *timer; 35 | @property (nonatomic, assign) int numSeconds; 36 | 37 | @end 38 | 39 | @implementation JBCountdownLabel 40 | 41 | - (instancetype)initWithFrame:(CGRect)frame format:(NSString *)string time:(int)seconds delegate:(id )delegate 42 | { 43 | NSAssert(seconds > 0, @"You must provide a positive amount of time."); 44 | 45 | self = [super initWithFrame:frame]; 46 | if (self) 47 | { 48 | self.numSeconds = seconds; 49 | self.stringFormat = string ?: @"%@"; 50 | self.delegate = delegate; 51 | 52 | [self defaultLabel]; 53 | [self restartCountdown]; 54 | [self updateLabel]; 55 | } 56 | return self; 57 | } 58 | 59 | #pragma mark - Public methods 60 | 61 | - (void)setTime:(int)seconds 62 | { 63 | self.numSeconds = seconds; 64 | self.expirationDate = [NSDate dateWithTimeIntervalSinceNow:self.numSeconds]; 65 | } 66 | 67 | - (void)restartCountdown 68 | { 69 | [self.timer invalidate]; 70 | 71 | self.expirationDate = [NSDate dateWithTimeIntervalSinceNow:self.numSeconds]; 72 | self.text = [NSString stringWithFormat:self.stringFormat, [self currentTimeString]]; 73 | self.timer = [NSTimer scheduledTimerWithTimeInterval:1 target:self selector:@selector(updateLabel) userInfo:nil repeats:YES]; 74 | } 75 | 76 | - (void)cancelCountdown 77 | { 78 | [self.timer invalidate]; 79 | self.expirationDate = [NSDate date]; 80 | self.text = [NSString stringWithFormat:self.stringFormat, [self currentTimeString]]; 81 | } 82 | 83 | #pragma mark - Private methods 84 | 85 | - (void)defaultLabel 86 | { 87 | self.backgroundColor = [UIColor clearColor]; 88 | self.textAlignment = NSTextAlignmentCenter; 89 | self.font = [UIFont boldSystemFontOfSize:17]; 90 | self.textColor = [UIColor darkTextColor]; 91 | self.shadowColor = [UIColor clearColor]; 92 | } 93 | 94 | - (void)updateLabel 95 | { 96 | NSString *currentTime = [self currentTimeString]; 97 | self.text = [NSString stringWithFormat:self.stringFormat, currentTime]; 98 | 99 | if ([[NSDate date] timeIntervalSinceDate:self.expirationDate] >= 0) 100 | { 101 | [self cancelCountdown]; 102 | if ([self.delegate respondsToSelector:@selector(countdownFinnishIn:)]) { 103 | [self.delegate countdownFinnishIn:self]; 104 | } 105 | } 106 | } 107 | 108 | - (NSString *)currentTimeString 109 | { 110 | NSDateComponents *countdown = [[NSCalendar currentCalendar] components:(NSHourCalendarUnit | NSMinuteCalendarUnit | NSSecondCalendarUnit) 111 | fromDate:[NSDate date] 112 | toDate:self.expirationDate 113 | options:0]; 114 | NSString *timeRemaining; 115 | 116 | if ([countdown hour] > 0) { 117 | timeRemaining = [NSString stringWithFormat:@"%02d:%02d:%02d",[countdown hour],[countdown minute], [countdown second]]; 118 | } 119 | else { 120 | timeRemaining = [NSString stringWithFormat:@"%02d:%02d",[countdown minute], [countdown second]]; 121 | } 122 | 123 | return timeRemaining; 124 | } 125 | 126 | @end 127 | -------------------------------------------------------------------------------- /JBCoundownLabelSampleProject/ViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.h 3 | // JBCoundownLabelSampleProject 4 | // 5 | // Created by Javier Berlana on 18/06/14. 6 | // Copyright (c) 2014 Javier Berlana. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface ViewController : UIViewController 12 | 13 | @end 14 | 15 | -------------------------------------------------------------------------------- /JBCoundownLabelSampleProject/ViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.m 3 | // JBCoundownLabelSampleProject 4 | // 5 | // Created by Javier Berlana on 18/06/14. 6 | // Copyright (c) 2014 Javier Berlana. All rights reserved. 7 | // 8 | 9 | #import "ViewController.h" 10 | 11 | // Views 12 | #import "JBCountdownLabel.h" 13 | 14 | @interface ViewController () 15 | 16 | @property (strong, nonatomic) JBCountdownLabel *countdownLabel; 17 | 18 | @end 19 | 20 | @implementation ViewController 21 | 22 | - (void)viewDidLoad 23 | { 24 | [super viewDidLoad]; 25 | 26 | // Add countdown to the view. 27 | self.countdownLabel = [[JBCountdownLabel alloc] initWithFrame:CGRectMake(0, 150, 320, 46) format:@"Initiating ignition in %@" time:10 delegate:self]; 28 | self.countdownLabel.textColor = [UIColor colorWithRed:0.48 green:0.63 blue:0.07 alpha:1]; 29 | [self.view addSubview:self.countdownLabel]; 30 | } 31 | 32 | - (void)viewDidDisappear:(BOOL)animated 33 | { 34 | [super viewDidDisappear:animated]; 35 | [self.countdownLabel cancelCountdown]; 36 | } 37 | 38 | - (void)didReceiveMemoryWarning 39 | { 40 | [super didReceiveMemoryWarning]; 41 | } 42 | 43 | - (UIStatusBarStyle)preferredStatusBarStyle 44 | { 45 | return UIStatusBarStyleLightContent; 46 | } 47 | 48 | #pragma mark - Countdown delegate 49 | 50 | - (void)countdownFinnishIn:(JBCountdownLabel *)countdown 51 | { 52 | UIAlertView *alert = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"Ignition started",) 53 | message:NSLocalizedString(@"The countdown has ended",) 54 | delegate:nil 55 | cancelButtonTitle:NSLocalizedString(@"Ok",) 56 | otherButtonTitles:nil]; 57 | [alert show]; 58 | } 59 | 60 | #pragma mark - Actions 61 | 62 | - (IBAction)restartCountdown:(id)sender 63 | { 64 | [self.countdownLabel restartCountdown]; 65 | } 66 | 67 | - (IBAction)cancelCountdown:(id)sender 68 | { 69 | [self.countdownLabel cancelCountdown]; 70 | } 71 | 72 | 73 | @end 74 | -------------------------------------------------------------------------------- /JBCoundownLabelSampleProject/en.lproj/InfoPlist.strings: -------------------------------------------------------------------------------- 1 | /* Localized versions of Info.plist keys */ 2 | 3 | -------------------------------------------------------------------------------- /JBCoundownLabelSampleProject/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // JBCoundownLabelSampleProject 4 | // 5 | // Created by Javier Berlana on 18/06/14. 6 | // Copyright (c) 2014 Javier Berlana. 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 | -------------------------------------------------------------------------------- /JBCoundownLabelSampleProjectTests/JBCoundownLabelSampleProjectTests-Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | ${EXECUTABLE_NAME} 9 | CFBundleIdentifier 10 | meets.${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 | -------------------------------------------------------------------------------- /JBCoundownLabelSampleProjectTests/JBCoundownLabelSampleProjectTests.m: -------------------------------------------------------------------------------- 1 | // 2 | // JBCoundownLabelSampleProjectTests.m 3 | // JBCoundownLabelSampleProjectTests 4 | // 5 | // Created by Javier Berlana on 18/06/14. 6 | // Copyright (c) 2014 Javier Berlana. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface JBCoundownLabelSampleProjectTests : XCTestCase 12 | 13 | @end 14 | 15 | @implementation JBCoundownLabelSampleProjectTests 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 | -------------------------------------------------------------------------------- /JBCoundownLabelSampleProjectTests/en.lproj/InfoPlist.strings: -------------------------------------------------------------------------------- 1 | /* Localized versions of Info.plist keys */ 2 | 3 | -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | Copyright (c) 2014 Javier Berlana @jberlana 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in 11 | all copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | THE SOFTWARE. 20 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # JBCountdownLabel 2 | 3 | **A `UILabel` subclass that displays a countdown** 4 | 5 | ![image]() 6 | 7 | `JBCountdownLabel` is `UILabel` subclass that displays a countdown with a defined amount of seconds. So you can customise the label just like a native `UILabel` and add some cool actions: 8 | 9 | - Customise the number of seconds on the countdown. 10 | - You can show just the countdown or the countdown inside a sentence, you chose. 11 | - Restart the countdown. 12 | - Cancel the countdown. 13 | - Change the amount of time on the countdown. 14 | 15 | ## Installation 16 | 17 | I recommend use [CocoaPods](http://cocoapods.org) to install JBCountdownLabel. Simply add the following line to your `Podfile`: 18 | 19 | #### Podfile 20 | 21 | ```ruby 22 | pod 'JBCountdownLabel' 23 | ``` 24 | 25 | But you can also just drop `JBCountdownLabel.m` and `JBCountdownLabel.h` in your project. 26 | 27 | ## Usage 28 | 29 | Add the label to your view: 30 | 31 | ``` objective-c 32 | self.countdownLabel = [[JBCountdownLabel alloc] initWithFrame:CGRectMake(0, 50, 320, 46) format:@"Initiating ignition in %@" time:300 delegate:self]; 33 | self.countdownLabel.textColor = [UIColor colorWithRed:0.48 green:0.63 blue:0.07 alpha:1]; 34 | [self.view addSubview:self.countdownLabel]; 35 | ``` 36 | 37 | You can change the countdown behaviour: 38 | 39 | ``` objective-c 40 | - (void)restartCountdown; 41 | - (void)cancelCountdown; 42 | - (void)setTime:(int)seconds; 43 | ``` 44 | 45 | There is an optional `delegate` callback to get notified when the countdown ended: 46 | 47 | ``` objective-c 48 | - (void)countdownFinnishInCountdown:(JBCountdownLabel *)countdown; 49 | ``` 50 | 51 | ## Demo 52 | 53 | Build and run the `JBCoundownLabelSampleProject` project in Xcode to see `JBCountdownLabel` in action. 54 | 55 | This code has been created originally to provide a countdown on the activation screen of [meets](http://www.meetsapp.com/ "meets") [Download the app](https://itunes.apple.com/us/app/meets-tienes-un-plan/id595441007 "meets") and test it for free! Feedback is welcome! 56 | 57 | 58 | ## Communication 59 | 60 | - If you **found a bug**, open an issue. 61 | - If you **have a feature request**, open an issue. 62 | - If you **want to contribute**, submit a pull request. 63 | 64 | ## Contact 65 | 66 | Javier Berlana 67 | 68 | - http://github.com/jberlana 69 | - http://twitter.com/jberlana 70 | - jberlana@gmail.com 71 | 72 | ## License 73 | 74 | JBCountdownLabel is available under the MIT license. See the LICENSE file for more info. 75 | 76 | -- 77 | ###[meets](http://www.meetsapp.com/ "meets"), create and discover plans with your friends.### 78 | -------------------------------------------------------------------------------- /demo.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jberlana/JBCountdownLabel/7f85f89978a251aee9b416bbab02b70426e6d7fe/demo.gif --------------------------------------------------------------------------------