├── README.md ├── 倒计时.xcodeproj ├── project.pbxproj ├── project.xcworkspace │ ├── contents.xcworkspacedata │ └── xcuserdata │ │ ├── hanjunqiang.xcuserdatad │ │ ├── UserInterfaceState.xcuserstate │ │ ├── UserInterfaceState_20160219204824.xcuserstate │ │ ├── UserInterfaceState_20160219204829.xcuserstate │ │ ├── UserInterfaceState_20160219204835.xcuserstate │ │ ├── UserInterfaceState_20160219205134.xcuserstate │ │ ├── UserInterfaceState_20160219205139.xcuserstate │ │ ├── UserInterfaceState_20160219205308.xcuserstate │ │ └── UserInterfaceState_20160219205313.xcuserstate │ │ └── zhengwenming.xcuserdatad │ │ └── UserInterfaceState.xcuserstate └── xcuserdata │ ├── hanjunqiang.xcuserdatad │ └── xcschemes │ │ ├── xcschememanagement.plist │ │ └── 倒计时.xcscheme │ └── zhengwenming.xcuserdatad │ ├── xcdebugger │ └── Breakpoints_v2.xcbkptlist │ └── xcschemes │ ├── xcschememanagement.plist │ └── 倒计时.xcscheme └── 倒计时 ├── AppDelegate.h ├── AppDelegate.m ├── Assets.xcassets └── AppIcon.appiconset │ └── Contents.json ├── Base.lproj ├── LaunchScreen.storyboard └── Main.storyboard ├── Info.plist ├── ViewController.h ├── ViewController.m └── main.m /README.md: -------------------------------------------------------------------------------- 1 | # CountDown 2 | iOS倒计时,显示 天、时、分、秒。比如:离活动结束还有 0天 01: 14: 59 3 | 4 | ### 效果如下: 5 | 6 | ![](http://img.blog.csdn.net/20160219205417733?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQv/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/Center) 7 | 8 | 9 | ## Star 10 | 11 | [CSDN博客](http://blog.csdn.net/qq_31810357) 12 | 13 | ### iOS开发者交流群:446310206 一起来学习吧! 14 | 15 | 喜欢就❤️❤️❤️star一下吧!你的支持是我更新的动力! Love is every every every star! Your support is my renewed motivation! 16 | 17 | 18 | ## License 19 | 20 | This code is distributed under the terms and conditions of the [MIT license](LICENSE). 21 | -------------------------------------------------------------------------------- /倒计时.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 70A541601C3E736A00EE3E17 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 70A5415F1C3E736A00EE3E17 /* main.m */; }; 11 | 70A541631C3E736A00EE3E17 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 70A541621C3E736A00EE3E17 /* AppDelegate.m */; }; 12 | 70A541661C3E736A00EE3E17 /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 70A541651C3E736A00EE3E17 /* ViewController.m */; }; 13 | 70A541691C3E736A00EE3E17 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 70A541671C3E736A00EE3E17 /* Main.storyboard */; }; 14 | 70A5416B1C3E736A00EE3E17 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 70A5416A1C3E736A00EE3E17 /* Assets.xcassets */; }; 15 | 70A5416E1C3E736A00EE3E17 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 70A5416C1C3E736A00EE3E17 /* LaunchScreen.storyboard */; }; 16 | /* End PBXBuildFile section */ 17 | 18 | /* Begin PBXFileReference section */ 19 | 70A5415B1C3E736A00EE3E17 /* 倒计时.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "倒计时.app"; sourceTree = BUILT_PRODUCTS_DIR; }; 20 | 70A5415F1C3E736A00EE3E17 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; 21 | 70A541611C3E736A00EE3E17 /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; 22 | 70A541621C3E736A00EE3E17 /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; }; 23 | 70A541641C3E736A00EE3E17 /* ViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ViewController.h; sourceTree = ""; }; 24 | 70A541651C3E736A00EE3E17 /* ViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ViewController.m; sourceTree = ""; }; 25 | 70A541681C3E736A00EE3E17 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 26 | 70A5416A1C3E736A00EE3E17 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 27 | 70A5416D1C3E736A00EE3E17 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 28 | 70A5416F1C3E736A00EE3E17 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 29 | /* End PBXFileReference section */ 30 | 31 | /* Begin PBXFrameworksBuildPhase section */ 32 | 70A541581C3E736A00EE3E17 /* Frameworks */ = { 33 | isa = PBXFrameworksBuildPhase; 34 | buildActionMask = 2147483647; 35 | files = ( 36 | ); 37 | runOnlyForDeploymentPostprocessing = 0; 38 | }; 39 | /* End PBXFrameworksBuildPhase section */ 40 | 41 | /* Begin PBXGroup section */ 42 | 70A541521C3E736A00EE3E17 = { 43 | isa = PBXGroup; 44 | children = ( 45 | 70A5415D1C3E736A00EE3E17 /* 倒计时 */, 46 | 70A5415C1C3E736A00EE3E17 /* Products */, 47 | ); 48 | sourceTree = ""; 49 | }; 50 | 70A5415C1C3E736A00EE3E17 /* Products */ = { 51 | isa = PBXGroup; 52 | children = ( 53 | 70A5415B1C3E736A00EE3E17 /* 倒计时.app */, 54 | ); 55 | name = Products; 56 | sourceTree = ""; 57 | }; 58 | 70A5415D1C3E736A00EE3E17 /* 倒计时 */ = { 59 | isa = PBXGroup; 60 | children = ( 61 | 70A541611C3E736A00EE3E17 /* AppDelegate.h */, 62 | 70A541621C3E736A00EE3E17 /* AppDelegate.m */, 63 | 70A541641C3E736A00EE3E17 /* ViewController.h */, 64 | 70A541651C3E736A00EE3E17 /* ViewController.m */, 65 | 70A541671C3E736A00EE3E17 /* Main.storyboard */, 66 | 70A5416A1C3E736A00EE3E17 /* Assets.xcassets */, 67 | 70A5416C1C3E736A00EE3E17 /* LaunchScreen.storyboard */, 68 | 70A5416F1C3E736A00EE3E17 /* Info.plist */, 69 | 70A5415E1C3E736A00EE3E17 /* Supporting Files */, 70 | ); 71 | path = "倒计时"; 72 | sourceTree = ""; 73 | }; 74 | 70A5415E1C3E736A00EE3E17 /* Supporting Files */ = { 75 | isa = PBXGroup; 76 | children = ( 77 | 70A5415F1C3E736A00EE3E17 /* main.m */, 78 | ); 79 | name = "Supporting Files"; 80 | sourceTree = ""; 81 | }; 82 | /* End PBXGroup section */ 83 | 84 | /* Begin PBXNativeTarget section */ 85 | 70A5415A1C3E736A00EE3E17 /* 倒计时 */ = { 86 | isa = PBXNativeTarget; 87 | buildConfigurationList = 70A541721C3E736A00EE3E17 /* Build configuration list for PBXNativeTarget "倒计时" */; 88 | buildPhases = ( 89 | 70A541571C3E736A00EE3E17 /* Sources */, 90 | 70A541581C3E736A00EE3E17 /* Frameworks */, 91 | 70A541591C3E736A00EE3E17 /* Resources */, 92 | ); 93 | buildRules = ( 94 | ); 95 | dependencies = ( 96 | ); 97 | name = "倒计时"; 98 | productName = "倒计时"; 99 | productReference = 70A5415B1C3E736A00EE3E17 /* 倒计时.app */; 100 | productType = "com.apple.product-type.application"; 101 | }; 102 | /* End PBXNativeTarget section */ 103 | 104 | /* Begin PBXProject section */ 105 | 70A541531C3E736A00EE3E17 /* Project object */ = { 106 | isa = PBXProject; 107 | attributes = { 108 | LastUpgradeCheck = 0720; 109 | ORGANIZATIONNAME = "郑文明"; 110 | TargetAttributes = { 111 | 70A5415A1C3E736A00EE3E17 = { 112 | CreatedOnToolsVersion = 7.2; 113 | }; 114 | }; 115 | }; 116 | buildConfigurationList = 70A541561C3E736A00EE3E17 /* Build configuration list for PBXProject "倒计时" */; 117 | compatibilityVersion = "Xcode 3.2"; 118 | developmentRegion = English; 119 | hasScannedForEncodings = 0; 120 | knownRegions = ( 121 | en, 122 | Base, 123 | ); 124 | mainGroup = 70A541521C3E736A00EE3E17; 125 | productRefGroup = 70A5415C1C3E736A00EE3E17 /* Products */; 126 | projectDirPath = ""; 127 | projectRoot = ""; 128 | targets = ( 129 | 70A5415A1C3E736A00EE3E17 /* 倒计时 */, 130 | ); 131 | }; 132 | /* End PBXProject section */ 133 | 134 | /* Begin PBXResourcesBuildPhase section */ 135 | 70A541591C3E736A00EE3E17 /* Resources */ = { 136 | isa = PBXResourcesBuildPhase; 137 | buildActionMask = 2147483647; 138 | files = ( 139 | 70A5416E1C3E736A00EE3E17 /* LaunchScreen.storyboard in Resources */, 140 | 70A5416B1C3E736A00EE3E17 /* Assets.xcassets in Resources */, 141 | 70A541691C3E736A00EE3E17 /* Main.storyboard in Resources */, 142 | ); 143 | runOnlyForDeploymentPostprocessing = 0; 144 | }; 145 | /* End PBXResourcesBuildPhase section */ 146 | 147 | /* Begin PBXSourcesBuildPhase section */ 148 | 70A541571C3E736A00EE3E17 /* Sources */ = { 149 | isa = PBXSourcesBuildPhase; 150 | buildActionMask = 2147483647; 151 | files = ( 152 | 70A541661C3E736A00EE3E17 /* ViewController.m in Sources */, 153 | 70A541631C3E736A00EE3E17 /* AppDelegate.m in Sources */, 154 | 70A541601C3E736A00EE3E17 /* main.m in Sources */, 155 | ); 156 | runOnlyForDeploymentPostprocessing = 0; 157 | }; 158 | /* End PBXSourcesBuildPhase section */ 159 | 160 | /* Begin PBXVariantGroup section */ 161 | 70A541671C3E736A00EE3E17 /* Main.storyboard */ = { 162 | isa = PBXVariantGroup; 163 | children = ( 164 | 70A541681C3E736A00EE3E17 /* Base */, 165 | ); 166 | name = Main.storyboard; 167 | sourceTree = ""; 168 | }; 169 | 70A5416C1C3E736A00EE3E17 /* LaunchScreen.storyboard */ = { 170 | isa = PBXVariantGroup; 171 | children = ( 172 | 70A5416D1C3E736A00EE3E17 /* Base */, 173 | ); 174 | name = LaunchScreen.storyboard; 175 | sourceTree = ""; 176 | }; 177 | /* End PBXVariantGroup section */ 178 | 179 | /* Begin XCBuildConfiguration section */ 180 | 70A541701C3E736A00EE3E17 /* Debug */ = { 181 | isa = XCBuildConfiguration; 182 | buildSettings = { 183 | ALWAYS_SEARCH_USER_PATHS = NO; 184 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 185 | CLANG_CXX_LIBRARY = "libc++"; 186 | CLANG_ENABLE_MODULES = YES; 187 | CLANG_ENABLE_OBJC_ARC = YES; 188 | CLANG_WARN_BOOL_CONVERSION = YES; 189 | CLANG_WARN_CONSTANT_CONVERSION = YES; 190 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 191 | CLANG_WARN_EMPTY_BODY = YES; 192 | CLANG_WARN_ENUM_CONVERSION = YES; 193 | CLANG_WARN_INT_CONVERSION = YES; 194 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 195 | CLANG_WARN_UNREACHABLE_CODE = YES; 196 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 197 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 198 | COPY_PHASE_STRIP = NO; 199 | DEBUG_INFORMATION_FORMAT = dwarf; 200 | ENABLE_STRICT_OBJC_MSGSEND = YES; 201 | ENABLE_TESTABILITY = YES; 202 | GCC_C_LANGUAGE_STANDARD = gnu99; 203 | GCC_DYNAMIC_NO_PIC = NO; 204 | GCC_NO_COMMON_BLOCKS = YES; 205 | GCC_OPTIMIZATION_LEVEL = 0; 206 | GCC_PREPROCESSOR_DEFINITIONS = ( 207 | "DEBUG=1", 208 | "$(inherited)", 209 | ); 210 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 211 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 212 | GCC_WARN_UNDECLARED_SELECTOR = YES; 213 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 214 | GCC_WARN_UNUSED_FUNCTION = YES; 215 | GCC_WARN_UNUSED_VARIABLE = YES; 216 | IPHONEOS_DEPLOYMENT_TARGET = 9.2; 217 | MTL_ENABLE_DEBUG_INFO = YES; 218 | ONLY_ACTIVE_ARCH = YES; 219 | SDKROOT = iphoneos; 220 | TARGETED_DEVICE_FAMILY = "1,2"; 221 | }; 222 | name = Debug; 223 | }; 224 | 70A541711C3E736A00EE3E17 /* Release */ = { 225 | isa = XCBuildConfiguration; 226 | buildSettings = { 227 | ALWAYS_SEARCH_USER_PATHS = NO; 228 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 229 | CLANG_CXX_LIBRARY = "libc++"; 230 | CLANG_ENABLE_MODULES = YES; 231 | CLANG_ENABLE_OBJC_ARC = YES; 232 | CLANG_WARN_BOOL_CONVERSION = YES; 233 | CLANG_WARN_CONSTANT_CONVERSION = YES; 234 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 235 | CLANG_WARN_EMPTY_BODY = YES; 236 | CLANG_WARN_ENUM_CONVERSION = YES; 237 | CLANG_WARN_INT_CONVERSION = YES; 238 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 239 | CLANG_WARN_UNREACHABLE_CODE = YES; 240 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 241 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 242 | COPY_PHASE_STRIP = NO; 243 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 244 | ENABLE_NS_ASSERTIONS = NO; 245 | ENABLE_STRICT_OBJC_MSGSEND = YES; 246 | GCC_C_LANGUAGE_STANDARD = gnu99; 247 | GCC_NO_COMMON_BLOCKS = YES; 248 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 249 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 250 | GCC_WARN_UNDECLARED_SELECTOR = YES; 251 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 252 | GCC_WARN_UNUSED_FUNCTION = YES; 253 | GCC_WARN_UNUSED_VARIABLE = YES; 254 | IPHONEOS_DEPLOYMENT_TARGET = 9.2; 255 | MTL_ENABLE_DEBUG_INFO = NO; 256 | SDKROOT = iphoneos; 257 | TARGETED_DEVICE_FAMILY = "1,2"; 258 | VALIDATE_PRODUCT = YES; 259 | }; 260 | name = Release; 261 | }; 262 | 70A541731C3E736A00EE3E17 /* Debug */ = { 263 | isa = XCBuildConfiguration; 264 | buildSettings = { 265 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 266 | INFOPLIST_FILE = "倒计时/Info.plist"; 267 | IPHONEOS_DEPLOYMENT_TARGET = 7.0; 268 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 269 | PRODUCT_BUNDLE_IDENTIFIER = "com.wenming.---"; 270 | PRODUCT_NAME = "$(TARGET_NAME)"; 271 | TARGETED_DEVICE_FAMILY = 1; 272 | }; 273 | name = Debug; 274 | }; 275 | 70A541741C3E736A00EE3E17 /* Release */ = { 276 | isa = XCBuildConfiguration; 277 | buildSettings = { 278 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 279 | INFOPLIST_FILE = "倒计时/Info.plist"; 280 | IPHONEOS_DEPLOYMENT_TARGET = 7.0; 281 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 282 | PRODUCT_BUNDLE_IDENTIFIER = "com.wenming.---"; 283 | PRODUCT_NAME = "$(TARGET_NAME)"; 284 | TARGETED_DEVICE_FAMILY = 1; 285 | }; 286 | name = Release; 287 | }; 288 | /* End XCBuildConfiguration section */ 289 | 290 | /* Begin XCConfigurationList section */ 291 | 70A541561C3E736A00EE3E17 /* Build configuration list for PBXProject "倒计时" */ = { 292 | isa = XCConfigurationList; 293 | buildConfigurations = ( 294 | 70A541701C3E736A00EE3E17 /* Debug */, 295 | 70A541711C3E736A00EE3E17 /* Release */, 296 | ); 297 | defaultConfigurationIsVisible = 0; 298 | defaultConfigurationName = Release; 299 | }; 300 | 70A541721C3E736A00EE3E17 /* Build configuration list for PBXNativeTarget "倒计时" */ = { 301 | isa = XCConfigurationList; 302 | buildConfigurations = ( 303 | 70A541731C3E736A00EE3E17 /* Debug */, 304 | 70A541741C3E736A00EE3E17 /* Release */, 305 | ); 306 | defaultConfigurationIsVisible = 0; 307 | }; 308 | /* End XCConfigurationList section */ 309 | }; 310 | rootObject = 70A541531C3E736A00EE3E17 /* Project object */; 311 | } 312 | -------------------------------------------------------------------------------- /倒计时.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /倒计时.xcodeproj/project.xcworkspace/xcuserdata/hanjunqiang.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xiaohange/CountDown/10b0bad336173ad78b30483d24b0c767b42836a4/倒计时.xcodeproj/project.xcworkspace/xcuserdata/hanjunqiang.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /倒计时.xcodeproj/project.xcworkspace/xcuserdata/hanjunqiang.xcuserdatad/UserInterfaceState_20160219204824.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xiaohange/CountDown/10b0bad336173ad78b30483d24b0c767b42836a4/倒计时.xcodeproj/project.xcworkspace/xcuserdata/hanjunqiang.xcuserdatad/UserInterfaceState_20160219204824.xcuserstate -------------------------------------------------------------------------------- /倒计时.xcodeproj/project.xcworkspace/xcuserdata/hanjunqiang.xcuserdatad/UserInterfaceState_20160219204829.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xiaohange/CountDown/10b0bad336173ad78b30483d24b0c767b42836a4/倒计时.xcodeproj/project.xcworkspace/xcuserdata/hanjunqiang.xcuserdatad/UserInterfaceState_20160219204829.xcuserstate -------------------------------------------------------------------------------- /倒计时.xcodeproj/project.xcworkspace/xcuserdata/hanjunqiang.xcuserdatad/UserInterfaceState_20160219204835.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xiaohange/CountDown/10b0bad336173ad78b30483d24b0c767b42836a4/倒计时.xcodeproj/project.xcworkspace/xcuserdata/hanjunqiang.xcuserdatad/UserInterfaceState_20160219204835.xcuserstate -------------------------------------------------------------------------------- /倒计时.xcodeproj/project.xcworkspace/xcuserdata/hanjunqiang.xcuserdatad/UserInterfaceState_20160219205134.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xiaohange/CountDown/10b0bad336173ad78b30483d24b0c767b42836a4/倒计时.xcodeproj/project.xcworkspace/xcuserdata/hanjunqiang.xcuserdatad/UserInterfaceState_20160219205134.xcuserstate -------------------------------------------------------------------------------- /倒计时.xcodeproj/project.xcworkspace/xcuserdata/hanjunqiang.xcuserdatad/UserInterfaceState_20160219205139.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xiaohange/CountDown/10b0bad336173ad78b30483d24b0c767b42836a4/倒计时.xcodeproj/project.xcworkspace/xcuserdata/hanjunqiang.xcuserdatad/UserInterfaceState_20160219205139.xcuserstate -------------------------------------------------------------------------------- /倒计时.xcodeproj/project.xcworkspace/xcuserdata/hanjunqiang.xcuserdatad/UserInterfaceState_20160219205308.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xiaohange/CountDown/10b0bad336173ad78b30483d24b0c767b42836a4/倒计时.xcodeproj/project.xcworkspace/xcuserdata/hanjunqiang.xcuserdatad/UserInterfaceState_20160219205308.xcuserstate -------------------------------------------------------------------------------- /倒计时.xcodeproj/project.xcworkspace/xcuserdata/hanjunqiang.xcuserdatad/UserInterfaceState_20160219205313.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xiaohange/CountDown/10b0bad336173ad78b30483d24b0c767b42836a4/倒计时.xcodeproj/project.xcworkspace/xcuserdata/hanjunqiang.xcuserdatad/UserInterfaceState_20160219205313.xcuserstate -------------------------------------------------------------------------------- /倒计时.xcodeproj/project.xcworkspace/xcuserdata/zhengwenming.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xiaohange/CountDown/10b0bad336173ad78b30483d24b0c767b42836a4/倒计时.xcodeproj/project.xcworkspace/xcuserdata/zhengwenming.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /倒计时.xcodeproj/xcuserdata/hanjunqiang.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | 倒计时.xcscheme 8 | 9 | orderHint 10 | 0 11 | 12 | 13 | SuppressBuildableAutocreation 14 | 15 | 70A5415A1C3E736A00EE3E17 16 | 17 | primary 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /倒计时.xcodeproj/xcuserdata/hanjunqiang.xcuserdatad/xcschemes/倒计时.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 32 | 33 | 39 | 40 | 41 | 42 | 43 | 44 | 54 | 56 | 62 | 63 | 64 | 65 | 66 | 67 | 73 | 75 | 81 | 82 | 83 | 84 | 86 | 87 | 90 | 91 | 92 | -------------------------------------------------------------------------------- /倒计时.xcodeproj/xcuserdata/zhengwenming.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 8 | 20 | 21 | 22 | 24 | 36 | 37 | 38 | 39 | 40 | -------------------------------------------------------------------------------- /倒计时.xcodeproj/xcuserdata/zhengwenming.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | 倒计时.xcscheme 8 | 9 | orderHint 10 | 0 11 | 12 | 13 | SuppressBuildableAutocreation 14 | 15 | 70A5415A1C3E736A00EE3E17 16 | 17 | primary 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /倒计时.xcodeproj/xcuserdata/zhengwenming.xcuserdatad/xcschemes/倒计时.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 32 | 33 | 39 | 40 | 41 | 42 | 43 | 44 | 54 | 56 | 62 | 63 | 64 | 65 | 66 | 67 | 73 | 75 | 81 | 82 | 83 | 84 | 86 | 87 | 90 | 91 | 92 | -------------------------------------------------------------------------------- /倒计时/AppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.h 3 | // 倒计时 4 | // 5 | // Created by 韩俊强 on 16/2/19. 6 | // Copyright © 2016年 韩俊强. 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 | -------------------------------------------------------------------------------- /倒计时/AppDelegate.m: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.m 3 | // 倒计时 4 | // 5 | // Created by 韩俊强 on 16/2/19. 6 | // Copyright © 2016年 韩俊强. 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 | -------------------------------------------------------------------------------- /倒计时/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 | } -------------------------------------------------------------------------------- /倒计时/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 | -------------------------------------------------------------------------------- /倒计时/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 | 32 | 43 | 54 | 64 | 74 | 80 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | -------------------------------------------------------------------------------- /倒计时/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 | 37 | UISupportedInterfaceOrientations~ipad 38 | 39 | UIInterfaceOrientationPortrait 40 | UIInterfaceOrientationPortraitUpsideDown 41 | UIInterfaceOrientationLandscapeLeft 42 | UIInterfaceOrientationLandscapeRight 43 | 44 | 45 | 46 | -------------------------------------------------------------------------------- /倒计时/ViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.h 3 | // 倒计时 4 | // 5 | // Created by 韩俊强 on 16/2/19. 6 | // Copyright © 2016年 韩俊强. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface ViewController : UIViewController 12 | 13 | @property (weak, nonatomic) IBOutlet UILabel *dayLabel; 14 | @property (weak, nonatomic) IBOutlet UILabel *hourLabel; 15 | @property (weak, nonatomic) IBOutlet UILabel *minuteLabel; 16 | @property (weak, nonatomic) IBOutlet UILabel *secondLabel; 17 | 18 | @end 19 | 20 | -------------------------------------------------------------------------------- /倒计时/ViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.m 3 | // 倒计时 4 | // 5 | // Created by 韩俊强 on 16/2/19. 6 | // Copyright © 2016年 韩俊强. All rights reserved. 7 | // 8 | 9 | #import "ViewController.h" 10 | 11 | @interface ViewController () 12 | { 13 | dispatch_source_t _timer; 14 | } 15 | @end 16 | 17 | @implementation ViewController 18 | /** 19 | * 获取当天的年月日的字符串 20 | * 这里测试用 21 | * @return 格式为年-月-日 22 | */ 23 | -(NSString *)getyyyymmdd{ 24 | NSDate *now = [NSDate date]; 25 | NSDateFormatter *formatDay = [[NSDateFormatter alloc] init]; 26 | formatDay.dateFormat = @"yyyy-MM-dd"; 27 | NSString *dayStr = [formatDay stringFromDate:now]; 28 | 29 | return dayStr; 30 | 31 | } 32 | - (void)viewDidLoad { 33 | [super viewDidLoad]; 34 | NSDateFormatter *dateFormatter=[[NSDateFormatter alloc] init]; 35 | [dateFormatter setDateFormat:@"yyyy-MM-dd"]; 36 | 37 | NSDate *endDate = [dateFormatter dateFromString:[self getyyyymmdd]]; 38 | NSDate *endDate_tomorrow = [[NSDate alloc] initWithTimeIntervalSinceReferenceDate:([endDate timeIntervalSinceReferenceDate] + 24*3600)]; 39 | NSDate *startDate = [NSDate date]; 40 | NSTimeInterval timeInterval =[endDate_tomorrow timeIntervalSinceDate:startDate]; 41 | 42 | if (_timer==nil) { 43 | __block int timeout = timeInterval; //倒计时时间 44 | 45 | if (timeout!=0) { 46 | dispatch_queue_t queue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0); 47 | _timer = dispatch_source_create(DISPATCH_SOURCE_TYPE_TIMER, 0, 0,queue); 48 | dispatch_source_set_timer(_timer,dispatch_walltime(NULL, 0),1.0*NSEC_PER_SEC, 0); //每秒执行 49 | dispatch_source_set_event_handler(_timer, ^{ 50 | if(timeout<=0){ //倒计时结束,关闭 51 | dispatch_source_cancel(_timer); 52 | _timer = nil; 53 | dispatch_async(dispatch_get_main_queue(), ^{ 54 | self.dayLabel.text = @""; 55 | self.hourLabel.text = @"00"; 56 | self.minuteLabel.text = @"00"; 57 | self.secondLabel.text = @"00"; 58 | }); 59 | }else{ 60 | int days = (int)(timeout/(3600*24)); 61 | if (days==0) { 62 | self.dayLabel.text = @""; 63 | } 64 | int hours = (int)((timeout-days*24*3600)/3600); 65 | int minute = (int)(timeout-days*24*3600-hours*3600)/60; 66 | int second = timeout-days*24*3600-hours*3600-minute*60; 67 | dispatch_async(dispatch_get_main_queue(), ^{ 68 | if (days==0) { 69 | self.dayLabel.text = @"0天"; 70 | }else{ 71 | self.dayLabel.text = [NSString stringWithFormat:@"%d天",days]; 72 | } 73 | if (hours<10) { 74 | self.hourLabel.text = [NSString stringWithFormat:@"0%d",hours]; 75 | }else{ 76 | self.hourLabel.text = [NSString stringWithFormat:@"%d",hours]; 77 | } 78 | if (minute<10) { 79 | self.minuteLabel.text = [NSString stringWithFormat:@"0%d",minute]; 80 | }else{ 81 | self.minuteLabel.text = [NSString stringWithFormat:@"%d",minute]; 82 | } 83 | if (second<10) { 84 | self.secondLabel.text = [NSString stringWithFormat:@"0%d",second]; 85 | }else{ 86 | self.secondLabel.text = [NSString stringWithFormat:@"%d",second]; 87 | } 88 | 89 | }); 90 | timeout--; 91 | } 92 | }); 93 | dispatch_resume(_timer); 94 | } 95 | } 96 | 97 | 98 | } 99 | 100 | - (void)didReceiveMemoryWarning { 101 | [super didReceiveMemoryWarning]; 102 | // Dispose of any resources that can be recreated. 103 | } 104 | 105 | @end 106 | -------------------------------------------------------------------------------- /倒计时/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // 倒计时 4 | // 5 | // Created by 韩俊强 on 16/2/19. 6 | // Copyright © 2016年 韩俊强. 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 | --------------------------------------------------------------------------------