From 523791006d9f69e1e4b7d3e77b83edfa287eff11 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=85=B0=E6=9F=B3=E9=94=8B?= <@445816317@qq.com> Date: Tue, 7 Feb 2017 16:30:33 +0800 Subject: [PATCH] -first commit --- .DS_Store | Bin 0 -> 6148 bytes LFCountDownButtonDemo/.DS_Store | Bin 0 -> 6148 bytes .../project.pbxproj | 337 ++++++++++++++++++ .../contents.xcworkspacedata | 7 + .../LFCountDownButtonDemo/.DS_Store | Bin 0 -> 6148 bytes .../AppIcon.appiconset/Contents.json | 93 +++++ .../Base.lproj/LaunchScreen.storyboard | 27 ++ .../Example/AppDelegate.h | 17 + .../Example/AppDelegate.m | 56 +++ .../Example/ViewController.h | 15 + .../Example/ViewController.m | 134 +++++++ .../Example/ViewController.xib | 65 ++++ .../LFCountDownButtonDemo/Example/main.m | 16 + .../LFCountDownButtonDemo/Info.plist | 43 +++ .../LFCountDownButton/LFCountDownButton.h | 42 +++ .../LFCountDownButton/LFCountDownButton.m | 137 +++++++ .../zh-Hans.lproj/LaunchScreen.storyboard | 27 ++ 17 files changed, 1016 insertions(+) create mode 100644 .DS_Store create mode 100644 LFCountDownButtonDemo/.DS_Store create mode 100644 LFCountDownButtonDemo/LFCountDownButtonDemo.xcodeproj/project.pbxproj create mode 100644 LFCountDownButtonDemo/LFCountDownButtonDemo.xcodeproj/project.xcworkspace/contents.xcworkspacedata create mode 100644 LFCountDownButtonDemo/LFCountDownButtonDemo/.DS_Store create mode 100644 LFCountDownButtonDemo/LFCountDownButtonDemo/Assets.xcassets/AppIcon.appiconset/Contents.json create mode 100644 LFCountDownButtonDemo/LFCountDownButtonDemo/Base.lproj/LaunchScreen.storyboard create mode 100644 LFCountDownButtonDemo/LFCountDownButtonDemo/Example/AppDelegate.h create mode 100644 LFCountDownButtonDemo/LFCountDownButtonDemo/Example/AppDelegate.m create mode 100644 LFCountDownButtonDemo/LFCountDownButtonDemo/Example/ViewController.h create mode 100644 LFCountDownButtonDemo/LFCountDownButtonDemo/Example/ViewController.m create mode 100644 LFCountDownButtonDemo/LFCountDownButtonDemo/Example/ViewController.xib create mode 100644 LFCountDownButtonDemo/LFCountDownButtonDemo/Example/main.m create mode 100644 LFCountDownButtonDemo/LFCountDownButtonDemo/Info.plist create mode 100644 LFCountDownButtonDemo/LFCountDownButtonDemo/LFCountDownButton/LFCountDownButton.h create mode 100644 LFCountDownButtonDemo/LFCountDownButtonDemo/LFCountDownButton/LFCountDownButton.m create mode 100644 LFCountDownButtonDemo/LFCountDownButtonDemo/zh-Hans.lproj/LaunchScreen.storyboard diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..930ed411b9aae25b9e389b3b883d28b073eccd83 GIT binary patch literal 6148 zcmeHK!Ab)$5S_GDw}{w-qQ_jk^-$4PJqXKM1;K+*(Su6erNu7PO=-6-S}Xe-`bU0& zzvE1jmX_+li>S<$$(u}OlHHe**#Lm>`i)J10suIugqb`xp9qbU&Pc|32!)=b4-v#r z1qI1WG&_DH1GIOmZ~{kgfV(!ie-U`tkMXB)SF6y3J5WK=>jZ5TVAfmEX@|YIRC*Vg zY;JCT!O7>H{E~BBYpJ9b`*FYL`Q1z13meVA+Gk3&$F?7whs~s3SUFHp?1xdaI}v_$ z5k?J_c&Z;YdU~EyKW<^JUZ`GJ9}LQs-J&e-m4`(+*x4x+<@Q!(ICPw~jm`bzo4bd{ z!PD^h#qcihFREqP;s{>R_yz^{wQkf_(Jf|;W*p7L$P6$8%)lREz#d=D;vacleoSV7 z8TdH{=zNfTKO?L@GY03QiJ0ZG;}G(SSrQqs9Ml3$v|{1rUuc2!XE;f25y*vA7$VJ D!TnrG literal 0 HcmV?d00001 diff --git a/LFCountDownButtonDemo/.DS_Store b/LFCountDownButtonDemo/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..21cb7bd147f8200fc1cf1f9707f0d59c55648648 GIT binary patch literal 6148 zcmeHK!AiqG5Pe%KRJ`;ecyo`Qgn}OsV)W!e=nn{uRHVs#OHbl<>k27t>K

x87*GX!M>OAvJQv-NUh*6gUCgmSjTQw0UN%;n z<1aEGwL8HrZg9n_t=6wb&UwpUU{wn|ph9>a&+A#Jr;K97arXO2T;LTG<|>(~!JMO~ z*>p6XgsM?u-p;qrScRe}7wrW2c)z@hdAIzJRVa6yv3XqG^`~y$tTA8=7z6ucKu&PV z;8@YDF<=ZB14{_Z^ZV8$5O GD+6CRz+3bH literal 0 HcmV?d00001 diff --git a/LFCountDownButtonDemo/LFCountDownButtonDemo.xcodeproj/project.pbxproj b/LFCountDownButtonDemo/LFCountDownButtonDemo.xcodeproj/project.pbxproj new file mode 100644 index 0000000..9dd1c0d --- /dev/null +++ b/LFCountDownButtonDemo/LFCountDownButtonDemo.xcodeproj/project.pbxproj @@ -0,0 +1,337 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 46; + objects = { + +/* Begin PBXBuildFile section */ + BE4C4D841E49B06000B41E06 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = BE4C4D831E49B06000B41E06 /* Assets.xcassets */; }; + BE4C4D871E49B06000B41E06 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = BE4C4D851E49B06000B41E06 /* LaunchScreen.storyboard */; }; + BE4C4D931E49B09D00B41E06 /* LFCountDownButton.m in Sources */ = {isa = PBXBuildFile; fileRef = BE4C4D911E49B09D00B41E06 /* LFCountDownButton.m */; }; + BE4C4D9B1E49B0A200B41E06 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = BE4C4D961E49B0A200B41E06 /* AppDelegate.m */; }; + BE4C4D9C1E49B0A200B41E06 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = BE4C4D971E49B0A200B41E06 /* main.m */; }; + BE4C4D9D1E49B0A200B41E06 /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = BE4C4D991E49B0A200B41E06 /* ViewController.m */; }; + BE4C4D9E1E49B0A200B41E06 /* ViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = BE4C4D9A1E49B0A200B41E06 /* ViewController.xib */; }; +/* End PBXBuildFile section */ + +/* Begin PBXFileReference section */ + BE4C4D741E49B06000B41E06 /* LFCountDownButtonDemo.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = LFCountDownButtonDemo.app; sourceTree = BUILT_PRODUCTS_DIR; }; + BE4C4D831E49B06000B41E06 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; + BE4C4D881E49B06000B41E06 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + BE4C4D901E49B09D00B41E06 /* LFCountDownButton.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LFCountDownButton.h; sourceTree = ""; }; + BE4C4D911E49B09D00B41E06 /* LFCountDownButton.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = LFCountDownButton.m; sourceTree = ""; }; + BE4C4D951E49B0A200B41E06 /* AppDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; + BE4C4D961E49B0A200B41E06 /* AppDelegate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; }; + BE4C4D971E49B0A200B41E06 /* main.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; + BE4C4D981E49B0A200B41E06 /* ViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ViewController.h; sourceTree = ""; }; + BE4C4D991E49B0A200B41E06 /* ViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ViewController.m; sourceTree = ""; }; + BE4C4D9A1E49B0A200B41E06 /* ViewController.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = ViewController.xib; sourceTree = ""; }; + BE4C4DAD1E49BB3800B41E06 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + BE4C4D711E49B06000B41E06 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + BE4C4D6B1E49B06000B41E06 = { + isa = PBXGroup; + children = ( + BE4C4D761E49B06000B41E06 /* LFCountDownButtonDemo */, + BE4C4D751E49B06000B41E06 /* Products */, + ); + sourceTree = ""; + }; + BE4C4D751E49B06000B41E06 /* Products */ = { + isa = PBXGroup; + children = ( + BE4C4D741E49B06000B41E06 /* LFCountDownButtonDemo.app */, + ); + name = Products; + sourceTree = ""; + }; + BE4C4D761E49B06000B41E06 /* LFCountDownButtonDemo */ = { + isa = PBXGroup; + children = ( + BE4C4D941E49B0A200B41E06 /* Example */, + BE4C4D8E1E49B09D00B41E06 /* LFCountDownButton */, + BE4C4D831E49B06000B41E06 /* Assets.xcassets */, + BE4C4D851E49B06000B41E06 /* LaunchScreen.storyboard */, + BE4C4D881E49B06000B41E06 /* Info.plist */, + BE4C4D771E49B06000B41E06 /* Supporting Files */, + ); + path = LFCountDownButtonDemo; + sourceTree = ""; + }; + BE4C4D771E49B06000B41E06 /* Supporting Files */ = { + isa = PBXGroup; + children = ( + ); + name = "Supporting Files"; + sourceTree = ""; + }; + BE4C4D8E1E49B09D00B41E06 /* LFCountDownButton */ = { + isa = PBXGroup; + children = ( + BE4C4D901E49B09D00B41E06 /* LFCountDownButton.h */, + BE4C4D911E49B09D00B41E06 /* LFCountDownButton.m */, + ); + path = LFCountDownButton; + sourceTree = ""; + }; + BE4C4D941E49B0A200B41E06 /* Example */ = { + isa = PBXGroup; + children = ( + BE4C4D971E49B0A200B41E06 /* main.m */, + BE4C4D951E49B0A200B41E06 /* AppDelegate.h */, + BE4C4D961E49B0A200B41E06 /* AppDelegate.m */, + BE4C4D981E49B0A200B41E06 /* ViewController.h */, + BE4C4D991E49B0A200B41E06 /* ViewController.m */, + BE4C4D9A1E49B0A200B41E06 /* ViewController.xib */, + ); + path = Example; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXNativeTarget section */ + BE4C4D731E49B06000B41E06 /* LFCountDownButtonDemo */ = { + isa = PBXNativeTarget; + buildConfigurationList = BE4C4D8B1E49B06000B41E06 /* Build configuration list for PBXNativeTarget "LFCountDownButtonDemo" */; + buildPhases = ( + BE4C4D701E49B06000B41E06 /* Sources */, + BE4C4D711E49B06000B41E06 /* Frameworks */, + BE4C4D721E49B06000B41E06 /* Resources */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = LFCountDownButtonDemo; + productName = LFCountDownButtonDemo; + productReference = BE4C4D741E49B06000B41E06 /* LFCountDownButtonDemo.app */; + productType = "com.apple.product-type.application"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + BE4C4D6C1E49B06000B41E06 /* Project object */ = { + isa = PBXProject; + attributes = { + LastUpgradeCheck = 0810; + ORGANIZATIONNAME = "柳锋兰"; + TargetAttributes = { + BE4C4D731E49B06000B41E06 = { + CreatedOnToolsVersion = 8.1; + DevelopmentTeam = HG2J8Z23E3; + ProvisioningStyle = Manual; + }; + }; + }; + buildConfigurationList = BE4C4D6F1E49B06000B41E06 /* Build configuration list for PBXProject "LFCountDownButtonDemo" */; + compatibilityVersion = "Xcode 3.2"; + developmentRegion = English; + hasScannedForEncodings = 0; + knownRegions = ( + en, + Base, + ); + mainGroup = BE4C4D6B1E49B06000B41E06; + productRefGroup = BE4C4D751E49B06000B41E06 /* Products */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + BE4C4D731E49B06000B41E06 /* LFCountDownButtonDemo */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXResourcesBuildPhase section */ + BE4C4D721E49B06000B41E06 /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + BE4C4D9E1E49B0A200B41E06 /* ViewController.xib in Resources */, + BE4C4D871E49B06000B41E06 /* LaunchScreen.storyboard in Resources */, + BE4C4D841E49B06000B41E06 /* Assets.xcassets in Resources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXResourcesBuildPhase section */ + +/* Begin PBXSourcesBuildPhase section */ + BE4C4D701E49B06000B41E06 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + BE4C4D931E49B09D00B41E06 /* LFCountDownButton.m in Sources */, + BE4C4D9C1E49B0A200B41E06 /* main.m in Sources */, + BE4C4D9B1E49B0A200B41E06 /* AppDelegate.m in Sources */, + BE4C4D9D1E49B0A200B41E06 /* ViewController.m in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin PBXVariantGroup section */ + BE4C4D851E49B06000B41E06 /* LaunchScreen.storyboard */ = { + isa = PBXVariantGroup; + children = ( + BE4C4DAD1E49BB3800B41E06 /* Base */, + ); + name = LaunchScreen.storyboard; + sourceTree = ""; + }; +/* End PBXVariantGroup section */ + +/* Begin XCBuildConfiguration section */ + BE4C4D891E49B06000B41E06 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES; + CLANG_ANALYZER_NONNULL = YES; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_SUSPICIOUS_MOVES = YES; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = dwarf; + ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_TESTABILITY = YES; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_DYNAMIC_NO_PIC = NO; + GCC_NO_COMMON_BLOCKS = YES; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + ); + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 10.1; + MTL_ENABLE_DEBUG_INFO = YES; + ONLY_ACTIVE_ARCH = YES; + SDKROOT = iphoneos; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = Debug; + }; + BE4C4D8A1E49B06000B41E06 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES; + CLANG_ANALYZER_NONNULL = YES; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_SUSPICIOUS_MOVES = YES; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + ENABLE_NS_ASSERTIONS = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_NO_COMMON_BLOCKS = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 10.1; + MTL_ENABLE_DEBUG_INFO = NO; + SDKROOT = iphoneos; + TARGETED_DEVICE_FAMILY = "1,2"; + VALIDATE_PRODUCT = YES; + }; + name = Release; + }; + BE4C4D8C1E49B06000B41E06 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + DEVELOPMENT_TEAM = HG2J8Z23E3; + INFOPLIST_FILE = LFCountDownButtonDemo/Info.plist; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; + PRODUCT_BUNDLE_IDENTIFIER = com.lanliufeng; + PRODUCT_NAME = "$(TARGET_NAME)"; + PROVISIONING_PROFILE = "df5fcd52-5143-4c8a-84ca-75ba432f1178"; + PROVISIONING_PROFILE_SPECIFIER = com.lanliufeng; + }; + name = Debug; + }; + BE4C4D8D1E49B06000B41E06 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + DEVELOPMENT_TEAM = ""; + INFOPLIST_FILE = LFCountDownButtonDemo/Info.plist; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; + PRODUCT_BUNDLE_IDENTIFIER = com.lanliufeng; + PRODUCT_NAME = "$(TARGET_NAME)"; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + BE4C4D6F1E49B06000B41E06 /* Build configuration list for PBXProject "LFCountDownButtonDemo" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + BE4C4D891E49B06000B41E06 /* Debug */, + BE4C4D8A1E49B06000B41E06 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + BE4C4D8B1E49B06000B41E06 /* Build configuration list for PBXNativeTarget "LFCountDownButtonDemo" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + BE4C4D8C1E49B06000B41E06 /* Debug */, + BE4C4D8D1E49B06000B41E06 /* Release */, + ); + defaultConfigurationIsVisible = 0; + }; +/* End XCConfigurationList section */ + }; + rootObject = BE4C4D6C1E49B06000B41E06 /* Project object */; +} diff --git a/LFCountDownButtonDemo/LFCountDownButtonDemo.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/LFCountDownButtonDemo/LFCountDownButtonDemo.xcodeproj/project.xcworkspace/contents.xcworkspacedata new file mode 100644 index 0000000..ecd4fbf --- /dev/null +++ b/LFCountDownButtonDemo/LFCountDownButtonDemo.xcodeproj/project.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,7 @@ + + + + + diff --git a/LFCountDownButtonDemo/LFCountDownButtonDemo/.DS_Store b/LFCountDownButtonDemo/LFCountDownButtonDemo/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..5008ddfcf53c02e82d7eee2e57c38e5672ef89f6 GIT binary patch literal 6148 zcmeH~Jr2S!425mzP>H1@V-^m;4Wg<&0T*E43hX&L&p$$qDprKhvt+--jT7}7np#A3 zem<@ulZcFPQ@L2!n>{z**++&mCkOWA81W14cNZlEfg7;MkzE(HCqgga^y>{tEnwC%0;vJ&^%eQ zLs35+`xjp>T0 + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/LFCountDownButtonDemo/LFCountDownButtonDemo/Example/AppDelegate.h b/LFCountDownButtonDemo/LFCountDownButtonDemo/Example/AppDelegate.h new file mode 100644 index 0000000..cd52ce0 --- /dev/null +++ b/LFCountDownButtonDemo/LFCountDownButtonDemo/Example/AppDelegate.h @@ -0,0 +1,17 @@ +// +// AppDelegate.h +// LFCountDownButton +// +// Created by 兰柳锋 on 2017/2/7. +// Copyright © 2017年 柳锋兰. All rights reserved. +// + +#import + +@interface AppDelegate : UIResponder + +@property (strong, nonatomic) UIWindow *window; + + +@end + diff --git a/LFCountDownButtonDemo/LFCountDownButtonDemo/Example/AppDelegate.m b/LFCountDownButtonDemo/LFCountDownButtonDemo/Example/AppDelegate.m new file mode 100644 index 0000000..f2673bd --- /dev/null +++ b/LFCountDownButtonDemo/LFCountDownButtonDemo/Example/AppDelegate.m @@ -0,0 +1,56 @@ +// +// AppDelegate.m +// LFCountDownButton +// +// Created by 兰柳锋 on 2017/2/7. +// Copyright © 2017年 柳锋兰. All rights reserved. +// + +#import "AppDelegate.h" +#import "ViewController.h" +@interface AppDelegate () + +@end + +@implementation AppDelegate + + +- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { + + self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; + self.window.backgroundColor = [UIColor whiteColor]; + self.window.rootViewController = [[UINavigationController alloc]initWithRootViewController:[[ViewController alloc]init]]; + [self.window makeKeyAndVisible]; + + return YES; +} + + +- (void)applicationWillResignActive:(UIApplication *)application { + // 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. + // Use this method to pause ongoing tasks, disable timers, and invalidate graphics rendering callbacks. Games should use this method to pause the game. +} + + +- (void)applicationDidEnterBackground:(UIApplication *)application { + // 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. + // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. +} + + +- (void)applicationWillEnterForeground:(UIApplication *)application { + // Called as part of the transition from the background to the active state; here you can undo many of the changes made on entering the background. +} + + +- (void)applicationDidBecomeActive:(UIApplication *)application { + // 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. +} + + +- (void)applicationWillTerminate:(UIApplication *)application { + // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. +} + + +@end diff --git a/LFCountDownButtonDemo/LFCountDownButtonDemo/Example/ViewController.h b/LFCountDownButtonDemo/LFCountDownButtonDemo/Example/ViewController.h new file mode 100644 index 0000000..09dbc34 --- /dev/null +++ b/LFCountDownButtonDemo/LFCountDownButtonDemo/Example/ViewController.h @@ -0,0 +1,15 @@ +// +// ViewController.h +// LFCountDownButton +// +// Created by 兰柳锋 on 2017/2/7. +// Copyright © 2017年 柳锋兰. All rights reserved. +// + +#import + +@interface ViewController : UIViewController + + +@end + diff --git a/LFCountDownButtonDemo/LFCountDownButtonDemo/Example/ViewController.m b/LFCountDownButtonDemo/LFCountDownButtonDemo/Example/ViewController.m new file mode 100644 index 0000000..06125f3 --- /dev/null +++ b/LFCountDownButtonDemo/LFCountDownButtonDemo/Example/ViewController.m @@ -0,0 +1,134 @@ +// +// ViewController.m +// LFCountDownButton +// +// Created by 兰柳锋 on 2017/2/7. +// Copyright © 2017年 柳锋兰. All rights reserved. +// + +#import "ViewController.h" +#import "LFCountDownButton.h" + +@interface ViewController () + +/**倒计时按钮*/ +@property(nonatomic,strong) LFCountDownButton *countDownButton; +@property (weak, nonatomic) IBOutlet LFCountDownButton *countDownButtonXib; + +@end + +@implementation ViewController + +- (void)viewDidLoad { + + [super viewDidLoad]; + + self.title = @"LFCountDownButtonDemo"; + + [self setupCountDownButtonPure]; + +} +#pragma mark - 纯代码 + +- (void)setupCountDownButtonPure{ + + //标题 + UILabel *titleLabel = [[UILabel alloc]initWithFrame:CGRectMake(10, 70, 150, 40)]; + titleLabel.text = @"Pure Code"; + titleLabel.textColor = [UIColor whiteColor]; + titleLabel.textAlignment = NSTextAlignmentCenter; + titleLabel.font = [UIFont systemFontOfSize:14.0f]; + titleLabel.backgroundColor = [UIColor redColor]; + [self.view addSubview:titleLabel]; + + //创建倒计时按钮 + self.countDownButton = [[LFCountDownButton alloc]init]; + self.countDownButton.frame = CGRectMake(10, 130, 150, 40); + [self.countDownButton.titleLabel setFont:[UIFont systemFontOfSize:14.0f]]; + [self.countDownButton setTitle:@"Start CountDown" forState:UIControlStateNormal]; + [self.countDownButton setBackgroundColor:[UIColor redColor]]; + [self.view addSubview:self.countDownButton]; + + // 1. 倒计时按钮点击 + [self.countDownButton touchCountDownButtonHandler:^(LFCountDownButton *countDownButton, NSInteger tag) { + + countDownButton.enabled = NO; + + //1.1开始倒计时 + [countDownButton startCountDownWithSecond:10]; + + //do something... + + //1.2 倒计时进行中 + [countDownButton countDownButtonChanging:^NSString *(LFCountDownButton *countDownButton, NSUInteger second) { + + NSString *title = [NSString stringWithFormat:@"%zd left",second]; + return title; + + }]; + + //1.3 倒计时结束 + [countDownButton countDownButtonFinished:^NSString *(LFCountDownButton *countDownButton, NSUInteger second) { + + countDownButton.enabled = YES; + return @"Obtain again"; + + }]; + + }]; + +} + +#pragma mark - Xib + +/** + 1.拖拽button控件到xib + 2.修改button控件的的类,button type要设置成custom 否则会闪动 + 3.设置IBAction方法 + + */ +- (IBAction)countDownButtonClickForXib:(id)sender { + + //要么拖拽方法的时候改变type(id改为LFCountDownButton类型),要么自己转下 + self.countDownButtonXib = (LFCountDownButton*)sender; + self.countDownButtonXib.enabled = NO; + + //1.1开始倒计时 + [ self.countDownButtonXib startCountDownWithSecond:10]; + + //do something... + + //1.2 倒计时进行中 + [ self.countDownButtonXib countDownButtonChanging:^NSString *(LFCountDownButton *countDownButton, NSUInteger second) { + + NSString *title = [NSString stringWithFormat:@"%zd left",second]; + return title; + + }]; + + //1.3 倒计时结束 + [ self.countDownButtonXib countDownButtonFinished:^NSString *(LFCountDownButton *countDownButton, NSUInteger second) { + + countDownButton.enabled = YES; + return @"Obtain again"; + }]; + +} + +#pragma mark - 停止倒计时 + +- (IBAction)stopCountDown:(id)sender { + + [self.countDownButton stopCountDown]; + [self.countDownButtonXib stopCountDown]; + +} + + +- (void)didReceiveMemoryWarning { + [super didReceiveMemoryWarning]; + +} + + +@end diff --git a/LFCountDownButtonDemo/LFCountDownButtonDemo/Example/ViewController.xib b/LFCountDownButtonDemo/LFCountDownButtonDemo/Example/ViewController.xib new file mode 100644 index 0000000..507b94c --- /dev/null +++ b/LFCountDownButtonDemo/LFCountDownButtonDemo/Example/ViewController.xib @@ -0,0 +1,65 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/LFCountDownButtonDemo/LFCountDownButtonDemo/Example/main.m b/LFCountDownButtonDemo/LFCountDownButtonDemo/Example/main.m new file mode 100644 index 0000000..ec3fa7d --- /dev/null +++ b/LFCountDownButtonDemo/LFCountDownButtonDemo/Example/main.m @@ -0,0 +1,16 @@ +// +// main.m +// LFCountDownButton +// +// Created by 兰柳锋 on 2017/2/7. +// Copyright © 2017年 柳锋兰. All rights reserved. +// + +#import +#import "AppDelegate.h" + +int main(int argc, char * argv[]) { + @autoreleasepool { + return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); + } +} diff --git a/LFCountDownButtonDemo/LFCountDownButtonDemo/Info.plist b/LFCountDownButtonDemo/LFCountDownButtonDemo/Info.plist new file mode 100644 index 0000000..c12df3b --- /dev/null +++ b/LFCountDownButtonDemo/LFCountDownButtonDemo/Info.plist @@ -0,0 +1,43 @@ + + + + + CFBundleDevelopmentRegion + en + CFBundleExecutable + $(EXECUTABLE_NAME) + CFBundleIdentifier + $(PRODUCT_BUNDLE_IDENTIFIER) + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + $(PRODUCT_NAME) + CFBundlePackageType + APPL + CFBundleShortVersionString + 1.0 + CFBundleVersion + 1 + LSRequiresIPhoneOS + + UILaunchStoryboardName + LaunchScreen + UIRequiredDeviceCapabilities + + armv7 + + UISupportedInterfaceOrientations + + UIInterfaceOrientationPortrait + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + + UISupportedInterfaceOrientations~ipad + + UIInterfaceOrientationPortrait + UIInterfaceOrientationPortraitUpsideDown + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + + + diff --git a/LFCountDownButtonDemo/LFCountDownButtonDemo/LFCountDownButton/LFCountDownButton.h b/LFCountDownButtonDemo/LFCountDownButtonDemo/LFCountDownButton/LFCountDownButton.h new file mode 100644 index 0000000..cd41e40 --- /dev/null +++ b/LFCountDownButtonDemo/LFCountDownButtonDemo/LFCountDownButton/LFCountDownButton.h @@ -0,0 +1,42 @@ +// +// LFCountDownButton.h +// LFCountDownButton +// +// Created by 兰柳锋 on 2017/2/7. +// Copyright © 2017年 柳锋兰. All rights reserved. +// + +#import + +@class LFCountDownButton; + +#pragma mark - BlockMethod + +/** 倒计时进行中 Countdown in progress */ +typedef NSString* (^countDownButtonChanging)(LFCountDownButton *countDownButton,NSUInteger second); +/** 倒计时结束 Countdown end */ +typedef NSString* (^countDownButtonFinished)(LFCountDownButton *countDownButton,NSUInteger second); +/** 点击倒计时按钮 Click the countdown button */ +typedef void (^touchedCountDownButtonHandler)(LFCountDownButton *countDownButton,NSInteger tag); + +@interface LFCountDownButton : UIButton + +#pragma mark - ClassMethod + +/** 倒计时点击回调 Countdown click callback */ +- (void)touchCountDownButtonHandler:(touchedCountDownButtonHandler)touchedCountDownButtonHandler; + +/** 倒计时进行中回调 Countdown running in progress callback */ +- (void)countDownButtonChanging:(countDownButtonChanging)countDownButtonChanging; + +/** 倒计时结束回调 Countdown end callback */ +- (void)countDownButtonFinished:(countDownButtonFinished)countDownButtonFinished; + +/** 开始倒计时 Start countdown */ +- (void)startCountDownWithSecond:(NSUInteger)second; + +/** 停止倒计时 Stop countdown */ +- (void)stopCountDown; + + +@end diff --git a/LFCountDownButtonDemo/LFCountDownButtonDemo/LFCountDownButton/LFCountDownButton.m b/LFCountDownButtonDemo/LFCountDownButtonDemo/LFCountDownButton/LFCountDownButton.m new file mode 100644 index 0000000..a6b9feb --- /dev/null +++ b/LFCountDownButtonDemo/LFCountDownButtonDemo/LFCountDownButton/LFCountDownButton.m @@ -0,0 +1,137 @@ +// +// LFCountDownButton.m +// LFCountDownButton +// +// Created by 兰柳锋 on 2017/2/7. +// Copyright © 2017年 柳锋兰. All rights reserved. +// + +#import "LFCountDownButton.h" + +@interface LFCountDownButton () + +/** 倒计时秒数 Countdown seconds */ +@property(nonatomic,assign) NSInteger second; +/** 倒计时总时间 Total countdown time */ +@property(nonatomic,assign) NSUInteger totalSecond; +/** 定时器 timer */ +@property(nonatomic,strong) NSTimer *timer; +/** 时间 timer*/ +@property(nonatomic,strong) NSDate *startDate; + +//Block + +@property(nonatomic,copy) countDownButtonChanging countDownButtonChanging; + +@property(nonatomic,copy) countDownButtonFinished countDownButtonFinished; + +@property(nonatomic,copy) touchedCountDownButtonHandler touchedCountDownButtonHandler; + + +@end + + +@implementation LFCountDownButton + +#pragma mark - Class方法 + +/** 倒计时点击回调 Countdown click callback */ +- (void)touchCountDownButtonHandler:(touchedCountDownButtonHandler)touchedCountDownButtonHandler{ + + _touchedCountDownButtonHandler = [touchedCountDownButtonHandler copy]; + + [self addTarget:self action:@selector(touchedBegin:) forControlEvents:UIControlEventTouchUpInside]; +} +/** 倒计时进行中 Countdown running in progress callback */ +- (void)countDownButtonChanging:(countDownButtonChanging)countDownButtonChanging{ + + _countDownButtonChanging = [countDownButtonChanging copy]; + +} +/** 倒计时结束 Countdown end callback */ +- (void)countDownButtonFinished:(countDownButtonFinished)countDownButtonFinished{ + + _countDownButtonFinished = [countDownButtonFinished copy]; + +} + +/** 开始倒计时 Start countdown */ +- (void)startCountDownWithSecond:(NSUInteger)second{ + + _second = second; + _totalSecond = second; + _timer = [NSTimer scheduledTimerWithTimeInterval:1.0 target:self selector:@selector(timerStart:) userInfo:nil repeats:YES]; + _startDate = [NSDate date]; + [[NSRunLoop currentRunLoop]addTimer:_timer forMode:NSRunLoopCommonModes]; + +} +/** 停止倒计时 Stop countdown */ +- (void)stopCountDown{ + + if (_timer) { + + if ([_timer respondsToSelector:@selector(isValid)]) + { + if ([_timer isValid]) + { + [_timer invalidate]; + _second = _totalSecond; + + if (_countDownButtonFinished) + { + [self setTitle:_countDownButtonFinished(self,_totalSecond)forState:UIControlStateNormal]; + [self setTitle:_countDownButtonFinished(self,_totalSecond)forState:UIControlStateDisabled]; + + } + else + { + [self setTitle:@"Obtain Again" forState:UIControlStateNormal]; + [self setTitle:@"Obtain Again" forState:UIControlStateDisabled]; + + } + } + } + } + +} + +#pragma mark - Selector方法 +/** 点击倒计时按钮 Click the countdown button */ +- (void)touchedBegin:(LFCountDownButton*)sender{ + + if (_touchedCountDownButtonHandler) { + + _touchedCountDownButtonHandler(sender,sender.tag); + } +} +/** 定时器 timer*/ +- (void)timerStart:(NSTimer *)theTimer { + + double deltaTime = [[NSDate date] timeIntervalSinceDate:_startDate]; + + _second = _totalSecond - (NSInteger)(deltaTime+0.5) ; + + if (_second <= 0.0) + { + [self stopCountDown]; + } + else + { + if (_countDownButtonChanging) + { + [self setTitle:_countDownButtonChanging(self,_second) forState:UIControlStateNormal]; + [self setTitle:_countDownButtonChanging(self,_second) forState:UIControlStateDisabled]; + + } + else + { + NSString *title = [NSString stringWithFormat:@"%zd left",_second]; + [self setTitle:title forState:UIControlStateNormal]; + [self setTitle:title forState:UIControlStateDisabled]; + + } + } + +} + +@end diff --git a/LFCountDownButtonDemo/LFCountDownButtonDemo/zh-Hans.lproj/LaunchScreen.storyboard b/LFCountDownButtonDemo/LFCountDownButtonDemo/zh-Hans.lproj/LaunchScreen.storyboard new file mode 100644 index 0000000..fdf3f97 --- /dev/null +++ b/LFCountDownButtonDemo/LFCountDownButtonDemo/zh-Hans.lproj/LaunchScreen.storyboard @@ -0,0 +1,27 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + +