├── 1.StarbucksCreditCardInteractionDemo ├── Podfile ├── StarbucksCreditCardInteractionDemo.xcodeproj │ ├── project.pbxproj │ ├── project.xcworkspace │ │ ├── contents.xcworkspacedata │ │ └── xcuserdata │ │ │ └── yanjianwen.xcuserdatad │ │ │ └── UserInterfaceState.xcuserstate │ └── xcuserdata │ │ └── yanjianwen.xcuserdatad │ │ └── xcschemes │ │ ├── StarbucksCreditCardInteractionDemo.xcscheme │ │ └── xcschememanagement.plist └── StarbucksCreditCardInteractionDemo │ ├── AppDelegate.h │ ├── AppDelegate.m │ ├── Assets.xcassets │ ├── AppIcon.appiconset │ │ ├── 120 - iPhone.png │ │ ├── 120 - iPhone@3x.png │ │ └── Contents.json │ ├── Contents.json │ ├── apple_pay.imageset │ │ ├── Contents.json │ │ ├── apple pay.png │ │ ├── apple pay@2x.png │ │ └── apple pay@3x.png │ ├── apple_pay_large.imageset │ │ ├── Contents.json │ │ ├── apple pay_large.png │ │ ├── apple pay_large@2x.png │ │ └── apple pay_large@3x.png │ ├── background_text.imageset │ │ ├── Contents.json │ │ ├── Mask Copy.png │ │ ├── Mask Copy@2x.png │ │ └── Mask Copy@3x.png │ ├── combined.imageset │ │ ├── Combined Shape.png │ │ ├── Combined Shape@2x.png │ │ ├── Combined Shape@3x.png │ │ └── Contents.json │ ├── cup.imageset │ │ ├── Contents.json │ │ ├── Cup.png │ │ ├── Cup@2x.png │ │ └── Cup@3x.png │ ├── master_card.imageset │ │ ├── Contents.json │ │ ├── master.png │ │ ├── master@2x.png │ │ └── master@3x.png │ ├── master_large.imageset │ │ ├── Contents.json │ │ ├── master_large.png │ │ ├── master_large@2x.png │ │ └── master_large@3x.png │ ├── oval.imageset │ │ ├── Contents.json │ │ ├── Oval 46.png │ │ ├── Oval 46@2x.png │ │ └── Oval 46@3x.png │ ├── starbucks_card.imageset │ │ ├── Contents.json │ │ ├── starbucks-card-png-flexprint-starbucks-gift-card.png │ │ ├── starbucks-card-png-flexprint-starbucks-gift-card@2x.png │ │ └── starbucks-card-png-flexprint-starbucks-gift-card@3x.png │ ├── visa_card.imageset │ │ ├── Contents.json │ │ ├── visa.png │ │ ├── visa@2x.png │ │ └── visa@3x.png │ └── visa_large.imageset │ │ ├── Contents.json │ │ ├── visa_large.png │ │ ├── visa_large@2x.png │ │ └── visa_large@3x.png │ ├── Base.lproj │ ├── LaunchScreen.storyboard │ ├── Main.storyboard │ └── Pay.storyboard │ ├── Info.plist │ ├── MainViewController.h │ ├── MainViewController.m │ ├── PayCardInfoViewController.h │ ├── PayCardInfoViewController.m │ ├── PaySuccessViewController.h │ ├── PaySuccessViewController.m │ ├── PayViewController.h │ ├── PayViewController.m │ ├── UIView+PopAnimation.h │ ├── UIView+PopAnimation.m │ ├── kit │ ├── SpecialKeyBoardView.h │ ├── SpecialKeyBoardView.m │ ├── TopBarPageVController │ │ ├── TopBarIndicatorView.h │ │ ├── TopBarIndicatorView.m │ │ ├── TopBarPageController.h │ │ ├── TopBarPageController.m │ │ ├── TopBarView+ExpandItem.h │ │ ├── TopBarView+ExpandItem.m │ │ ├── TopBarView.h │ │ ├── TopBarView.m │ │ ├── UIColor+Fade.h │ │ └── UIColor+Fade.m │ ├── YanBannerView │ │ ├── YanBannerView.h │ │ ├── YanBannerView.m │ │ ├── YanBannerViewCell.h │ │ └── YanBannerViewCell.m │ └── iCarousel │ │ ├── iCarousel.h │ │ └── iCarousel.m │ └── main.m ├── 2.CrossFadePage-swift ├── CrossFadeLoginPage.xcodeproj │ ├── project.pbxproj │ ├── project.xcworkspace │ │ ├── contents.xcworkspacedata │ │ └── xcuserdata │ │ │ └── yanjianwen.xcuserdatad │ │ │ └── UserInterfaceState.xcuserstate │ └── xcuserdata │ │ └── yanjianwen.xcuserdatad │ │ ├── xcdebugger │ │ └── Breakpoints_v2.xcbkptlist │ │ └── xcschemes │ │ ├── CrossFadeLoginPage.xcscheme │ │ └── xcschememanagement.plist └── CrossFadeLoginPage │ ├── AppDelegate.swift │ ├── Assets.xcassets │ ├── AppIcon.appiconset │ │ └── Contents.json │ ├── Contents.json │ ├── TokyoStyle1.imageset │ │ ├── Contents.json │ │ └── Magnificent Illustrations of Tokyo by Mateusz Urbanowicz 2.jpeg │ ├── TokyoStyle2.imageset │ │ ├── Contents.json │ │ └── Magnificent Illustrations of Tokyo by Mateusz Urbanowicz.jpeg │ ├── TokyoStyle3.imageset │ │ ├── Contents.json │ │ └── Magnificent Illustrations of Tokyo by Mateusz Urbanowicz 4.jpeg │ ├── TokyoStyle4.imageset │ │ ├── Contents.json │ │ └── Magnificent Illustrations of Tokyo by Mateusz Urbanowicz 5.jpeg │ ├── TokyoStyle5.imageset │ │ ├── Contents.json │ │ └── Magnificent Illustrations of Tokyo by Mateusz Urbanowicz 6.jpeg │ ├── TokyoStyle6.imageset │ │ ├── Contents.json │ │ └── Group 5.png │ └── TokyoStyle7.imageset │ │ ├── Contents.json │ │ └── Group 5.png │ ├── Base.lproj │ ├── LaunchScreen.storyboard │ └── Main.storyboard │ ├── CrossfadingImageView.swift │ ├── Info.plist │ ├── ViewController.swift │ └── bg.mp3 ├── README.md └── readme-assets ├── CrossFadePage.gif ├── StarbucksCreditCardInteractioPayStoryboardFix.gif └── StarbucksCreditCardInteractionDemo.gif /1.StarbucksCreditCardInteractionDemo/Podfile: -------------------------------------------------------------------------------- 1 | platform :ios, '7.0' 2 | pod 'pop', '~> 1.0' 3 | pod 'ChameleonFramework', '~> 2.0' 4 | pod 'Masonry' 5 | pod 'IQKeyboardManager' 6 | 7 | -------------------------------------------------------------------------------- /1.StarbucksCreditCardInteractionDemo/StarbucksCreditCardInteractionDemo.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 7E1B00CE1CF998A4004FEE48 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 7E1B00CD1CF998A4004FEE48 /* main.m */; }; 11 | 7E1B00D11CF998A4004FEE48 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 7E1B00D01CF998A4004FEE48 /* AppDelegate.m */; }; 12 | 7E1B00D41CF998A4004FEE48 /* MainViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 7E1B00D31CF998A4004FEE48 /* MainViewController.m */; }; 13 | 7E1B00D71CF998A4004FEE48 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 7E1B00D51CF998A4004FEE48 /* Main.storyboard */; }; 14 | 7E1B00D91CF998A4004FEE48 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 7E1B00D81CF998A4004FEE48 /* Assets.xcassets */; }; 15 | 7E1B00DC1CF998A4004FEE48 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 7E1B00DA1CF998A4004FEE48 /* LaunchScreen.storyboard */; }; 16 | 7E1B01131CF9A201004FEE48 /* TopBarIndicatorView.m in Sources */ = {isa = PBXBuildFile; fileRef = 7E1B01001CF9A201004FEE48 /* TopBarIndicatorView.m */; }; 17 | 7E1B01141CF9A201004FEE48 /* TopBarPageController.m in Sources */ = {isa = PBXBuildFile; fileRef = 7E1B01021CF9A201004FEE48 /* TopBarPageController.m */; }; 18 | 7E1B01151CF9A201004FEE48 /* TopBarView+ExpandItem.m in Sources */ = {isa = PBXBuildFile; fileRef = 7E1B01041CF9A201004FEE48 /* TopBarView+ExpandItem.m */; }; 19 | 7E1B01161CF9A201004FEE48 /* TopBarView.m in Sources */ = {isa = PBXBuildFile; fileRef = 7E1B01061CF9A201004FEE48 /* TopBarView.m */; }; 20 | 7E1B01171CF9A201004FEE48 /* UIColor+Fade.m in Sources */ = {isa = PBXBuildFile; fileRef = 7E1B01081CF9A201004FEE48 /* UIColor+Fade.m */; }; 21 | 7E1B011A1CF9D230004FEE48 /* Pay.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 7E1B01181CF9D22F004FEE48 /* Pay.storyboard */; }; 22 | 7E1B011D1CF9D25A004FEE48 /* PayViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 7E1B011C1CF9D25A004FEE48 /* PayViewController.m */; }; 23 | 7E1B01211CFB08B3004FEE48 /* iCarousel.m in Sources */ = {isa = PBXBuildFile; fileRef = 7E1B01201CFB08B3004FEE48 /* iCarousel.m */; }; 24 | 7E1B01251CFC861E004FEE48 /* PayCardInfoViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 7E1B01241CFC861E004FEE48 /* PayCardInfoViewController.m */; }; 25 | 7E9CB97F1CFEA53500B5F4C3 /* UIView+PopAnimation.m in Sources */ = {isa = PBXBuildFile; fileRef = 7E9CB97E1CFEA53500B5F4C3 /* UIView+PopAnimation.m */; }; 26 | 7E9CB9851D001C6B00B5F4C3 /* YanBannerView.m in Sources */ = {isa = PBXBuildFile; fileRef = 7E9CB9821D001C6B00B5F4C3 /* YanBannerView.m */; }; 27 | 7E9CB9861D001C6B00B5F4C3 /* YanBannerViewCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 7E9CB9841D001C6B00B5F4C3 /* YanBannerViewCell.m */; }; 28 | 7E9CB98A1D01AFE200B5F4C3 /* SpecialKeyBoardView.m in Sources */ = {isa = PBXBuildFile; fileRef = 7E9CB9891D01AFE200B5F4C3 /* SpecialKeyBoardView.m */; }; 29 | 7EF8C08F1D056AD400D6B608 /* PaySuccessViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 7EF8C08E1D056AD400D6B608 /* PaySuccessViewController.m */; }; 30 | 7EF8C11A1D0668AE00D6B608 /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 7EF8C1191D0668AE00D6B608 /* CoreGraphics.framework */; }; 31 | D2672F411B585D65DBF67FC5 /* libPods.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 85693C4A007911B254E14E08 /* libPods.a */; }; 32 | /* End PBXBuildFile section */ 33 | 34 | /* Begin PBXFileReference section */ 35 | 7E1B00C91CF998A4004FEE48 /* StarbucksCreditCardInteractionDemo.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = StarbucksCreditCardInteractionDemo.app; sourceTree = BUILT_PRODUCTS_DIR; }; 36 | 7E1B00CD1CF998A4004FEE48 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; 37 | 7E1B00CF1CF998A4004FEE48 /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; 38 | 7E1B00D01CF998A4004FEE48 /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; }; 39 | 7E1B00D21CF998A4004FEE48 /* MainViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MainViewController.h; sourceTree = ""; }; 40 | 7E1B00D31CF998A4004FEE48 /* MainViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MainViewController.m; sourceTree = ""; }; 41 | 7E1B00D61CF998A4004FEE48 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 42 | 7E1B00D81CF998A4004FEE48 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 43 | 7E1B00DB1CF998A4004FEE48 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 44 | 7E1B00DD1CF998A4004FEE48 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 45 | 7E1B00FF1CF9A201004FEE48 /* TopBarIndicatorView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TopBarIndicatorView.h; sourceTree = ""; }; 46 | 7E1B01001CF9A201004FEE48 /* TopBarIndicatorView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TopBarIndicatorView.m; sourceTree = ""; }; 47 | 7E1B01011CF9A201004FEE48 /* TopBarPageController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TopBarPageController.h; sourceTree = ""; }; 48 | 7E1B01021CF9A201004FEE48 /* TopBarPageController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TopBarPageController.m; sourceTree = ""; }; 49 | 7E1B01031CF9A201004FEE48 /* TopBarView+ExpandItem.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "TopBarView+ExpandItem.h"; sourceTree = ""; }; 50 | 7E1B01041CF9A201004FEE48 /* TopBarView+ExpandItem.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "TopBarView+ExpandItem.m"; sourceTree = ""; }; 51 | 7E1B01051CF9A201004FEE48 /* TopBarView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TopBarView.h; sourceTree = ""; }; 52 | 7E1B01061CF9A201004FEE48 /* TopBarView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TopBarView.m; sourceTree = ""; }; 53 | 7E1B01071CF9A201004FEE48 /* UIColor+Fade.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UIColor+Fade.h"; sourceTree = ""; }; 54 | 7E1B01081CF9A201004FEE48 /* UIColor+Fade.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UIColor+Fade.m"; sourceTree = ""; }; 55 | 7E1B01191CF9D230004FEE48 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Pay.storyboard; sourceTree = ""; }; 56 | 7E1B011B1CF9D25A004FEE48 /* PayViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PayViewController.h; sourceTree = ""; }; 57 | 7E1B011C1CF9D25A004FEE48 /* PayViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PayViewController.m; sourceTree = ""; }; 58 | 7E1B011F1CFB08B3004FEE48 /* iCarousel.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = iCarousel.h; sourceTree = ""; }; 59 | 7E1B01201CFB08B3004FEE48 /* iCarousel.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = iCarousel.m; sourceTree = ""; }; 60 | 7E1B01231CFC861E004FEE48 /* PayCardInfoViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PayCardInfoViewController.h; sourceTree = ""; }; 61 | 7E1B01241CFC861E004FEE48 /* PayCardInfoViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PayCardInfoViewController.m; sourceTree = ""; }; 62 | 7E9CB97D1CFEA53500B5F4C3 /* UIView+PopAnimation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UIView+PopAnimation.h"; sourceTree = ""; }; 63 | 7E9CB97E1CFEA53500B5F4C3 /* UIView+PopAnimation.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UIView+PopAnimation.m"; sourceTree = ""; }; 64 | 7E9CB9811D001C6B00B5F4C3 /* YanBannerView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = YanBannerView.h; path = kit/YanBannerView/YanBannerView.h; sourceTree = ""; }; 65 | 7E9CB9821D001C6B00B5F4C3 /* YanBannerView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = YanBannerView.m; path = kit/YanBannerView/YanBannerView.m; sourceTree = ""; }; 66 | 7E9CB9831D001C6B00B5F4C3 /* YanBannerViewCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = YanBannerViewCell.h; path = kit/YanBannerView/YanBannerViewCell.h; sourceTree = ""; }; 67 | 7E9CB9841D001C6B00B5F4C3 /* YanBannerViewCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = YanBannerViewCell.m; path = kit/YanBannerView/YanBannerViewCell.m; sourceTree = ""; }; 68 | 7E9CB9881D01AFE200B5F4C3 /* SpecialKeyBoardView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SpecialKeyBoardView.h; path = kit/SpecialKeyBoardView.h; sourceTree = ""; }; 69 | 7E9CB9891D01AFE200B5F4C3 /* SpecialKeyBoardView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = SpecialKeyBoardView.m; path = kit/SpecialKeyBoardView.m; sourceTree = ""; }; 70 | 7EF8C08D1D056AD400D6B608 /* PaySuccessViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PaySuccessViewController.h; sourceTree = ""; }; 71 | 7EF8C08E1D056AD400D6B608 /* PaySuccessViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PaySuccessViewController.m; sourceTree = ""; }; 72 | 7EF8C1191D0668AE00D6B608 /* CoreGraphics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreGraphics.framework; path = System/Library/Frameworks/CoreGraphics.framework; sourceTree = SDKROOT; }; 73 | 85693C4A007911B254E14E08 /* libPods.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libPods.a; sourceTree = BUILT_PRODUCTS_DIR; }; 74 | 9E3F595628878A50CC7DBA9E /* Pods.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = Pods.debug.xcconfig; path = "Pods/Target Support Files/Pods/Pods.debug.xcconfig"; sourceTree = ""; }; 75 | DD7F2462AD94BF54466DEAD2 /* Pods.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = Pods.release.xcconfig; path = "Pods/Target Support Files/Pods/Pods.release.xcconfig"; sourceTree = ""; }; 76 | /* End PBXFileReference section */ 77 | 78 | /* Begin PBXFrameworksBuildPhase section */ 79 | 7E1B00C61CF998A4004FEE48 /* Frameworks */ = { 80 | isa = PBXFrameworksBuildPhase; 81 | buildActionMask = 2147483647; 82 | files = ( 83 | 7EF8C11A1D0668AE00D6B608 /* CoreGraphics.framework in Frameworks */, 84 | D2672F411B585D65DBF67FC5 /* libPods.a in Frameworks */, 85 | ); 86 | runOnlyForDeploymentPostprocessing = 0; 87 | }; 88 | /* End PBXFrameworksBuildPhase section */ 89 | 90 | /* Begin PBXGroup section */ 91 | 52470CB3D79A22C439AC58AC /* Pods */ = { 92 | isa = PBXGroup; 93 | children = ( 94 | 9E3F595628878A50CC7DBA9E /* Pods.debug.xcconfig */, 95 | DD7F2462AD94BF54466DEAD2 /* Pods.release.xcconfig */, 96 | ); 97 | name = Pods; 98 | sourceTree = ""; 99 | }; 100 | 7E1B00C01CF998A4004FEE48 = { 101 | isa = PBXGroup; 102 | children = ( 103 | 7E1B00CB1CF998A4004FEE48 /* StarbucksCreditCardInteractionDemo */, 104 | 7E1B00CA1CF998A4004FEE48 /* Products */, 105 | 52470CB3D79A22C439AC58AC /* Pods */, 106 | B8E501DBB3BE44B925656D03 /* Frameworks */, 107 | ); 108 | sourceTree = ""; 109 | }; 110 | 7E1B00CA1CF998A4004FEE48 /* Products */ = { 111 | isa = PBXGroup; 112 | children = ( 113 | 7E1B00C91CF998A4004FEE48 /* StarbucksCreditCardInteractionDemo.app */, 114 | ); 115 | name = Products; 116 | sourceTree = ""; 117 | }; 118 | 7E1B00CB1CF998A4004FEE48 /* StarbucksCreditCardInteractionDemo */ = { 119 | isa = PBXGroup; 120 | children = ( 121 | 7E1B00CF1CF998A4004FEE48 /* AppDelegate.h */, 122 | 7E1B00D01CF998A4004FEE48 /* AppDelegate.m */, 123 | 7E1B00E31CF9A1EB004FEE48 /* Kit */, 124 | 7E1B01221CFBCF7F004FEE48 /* category */, 125 | 7E1B00D21CF998A4004FEE48 /* MainViewController.h */, 126 | 7E1B00D31CF998A4004FEE48 /* MainViewController.m */, 127 | 7E1B011B1CF9D25A004FEE48 /* PayViewController.h */, 128 | 7E1B011C1CF9D25A004FEE48 /* PayViewController.m */, 129 | 7E1B01231CFC861E004FEE48 /* PayCardInfoViewController.h */, 130 | 7E1B01241CFC861E004FEE48 /* PayCardInfoViewController.m */, 131 | 7EF8C08D1D056AD400D6B608 /* PaySuccessViewController.h */, 132 | 7EF8C08E1D056AD400D6B608 /* PaySuccessViewController.m */, 133 | 7E1B00D51CF998A4004FEE48 /* Main.storyboard */, 134 | 7E1B01181CF9D22F004FEE48 /* Pay.storyboard */, 135 | 7E1B00D81CF998A4004FEE48 /* Assets.xcassets */, 136 | 7E1B00DA1CF998A4004FEE48 /* LaunchScreen.storyboard */, 137 | 7E1B00DD1CF998A4004FEE48 /* Info.plist */, 138 | 7E1B00CC1CF998A4004FEE48 /* Supporting Files */, 139 | ); 140 | path = StarbucksCreditCardInteractionDemo; 141 | sourceTree = ""; 142 | }; 143 | 7E1B00CC1CF998A4004FEE48 /* Supporting Files */ = { 144 | isa = PBXGroup; 145 | children = ( 146 | 7E1B00CD1CF998A4004FEE48 /* main.m */, 147 | ); 148 | name = "Supporting Files"; 149 | sourceTree = ""; 150 | }; 151 | 7E1B00E31CF9A1EB004FEE48 /* Kit */ = { 152 | isa = PBXGroup; 153 | children = ( 154 | 7E9CB9801D001BD400B5F4C3 /* YanBannerView */, 155 | 7E1B00FE1CF9A201004FEE48 /* TopBarPageVController */, 156 | 7E1B011E1CFB08B3004FEE48 /* iCarousel */, 157 | 7EF8C11B1D06722900D6B608 /* IQKeyboardManager */, 158 | ); 159 | name = Kit; 160 | sourceTree = ""; 161 | }; 162 | 7E1B00FE1CF9A201004FEE48 /* TopBarPageVController */ = { 163 | isa = PBXGroup; 164 | children = ( 165 | 7E1B00FF1CF9A201004FEE48 /* TopBarIndicatorView.h */, 166 | 7E1B01001CF9A201004FEE48 /* TopBarIndicatorView.m */, 167 | 7E1B01011CF9A201004FEE48 /* TopBarPageController.h */, 168 | 7E1B01021CF9A201004FEE48 /* TopBarPageController.m */, 169 | 7E1B01031CF9A201004FEE48 /* TopBarView+ExpandItem.h */, 170 | 7E1B01041CF9A201004FEE48 /* TopBarView+ExpandItem.m */, 171 | 7E1B01051CF9A201004FEE48 /* TopBarView.h */, 172 | 7E1B01061CF9A201004FEE48 /* TopBarView.m */, 173 | 7E1B01071CF9A201004FEE48 /* UIColor+Fade.h */, 174 | 7E1B01081CF9A201004FEE48 /* UIColor+Fade.m */, 175 | ); 176 | name = TopBarPageVController; 177 | path = kit/TopBarPageVController; 178 | sourceTree = ""; 179 | }; 180 | 7E1B011E1CFB08B3004FEE48 /* iCarousel */ = { 181 | isa = PBXGroup; 182 | children = ( 183 | 7E1B011F1CFB08B3004FEE48 /* iCarousel.h */, 184 | 7E1B01201CFB08B3004FEE48 /* iCarousel.m */, 185 | ); 186 | name = iCarousel; 187 | path = kit/iCarousel; 188 | sourceTree = ""; 189 | }; 190 | 7E1B01221CFBCF7F004FEE48 /* category */ = { 191 | isa = PBXGroup; 192 | children = ( 193 | 7E9CB97D1CFEA53500B5F4C3 /* UIView+PopAnimation.h */, 194 | 7E9CB97E1CFEA53500B5F4C3 /* UIView+PopAnimation.m */, 195 | ); 196 | name = category; 197 | sourceTree = ""; 198 | }; 199 | 7E9CB9801D001BD400B5F4C3 /* YanBannerView */ = { 200 | isa = PBXGroup; 201 | children = ( 202 | 7E9CB9811D001C6B00B5F4C3 /* YanBannerView.h */, 203 | 7E9CB9821D001C6B00B5F4C3 /* YanBannerView.m */, 204 | 7E9CB9831D001C6B00B5F4C3 /* YanBannerViewCell.h */, 205 | 7E9CB9841D001C6B00B5F4C3 /* YanBannerViewCell.m */, 206 | ); 207 | name = YanBannerView; 208 | sourceTree = ""; 209 | }; 210 | 7EF8C11B1D06722900D6B608 /* IQKeyboardManager */ = { 211 | isa = PBXGroup; 212 | children = ( 213 | 7E9CB9881D01AFE200B5F4C3 /* SpecialKeyBoardView.h */, 214 | 7E9CB9891D01AFE200B5F4C3 /* SpecialKeyBoardView.m */, 215 | ); 216 | name = IQKeyboardManager; 217 | sourceTree = ""; 218 | }; 219 | B8E501DBB3BE44B925656D03 /* Frameworks */ = { 220 | isa = PBXGroup; 221 | children = ( 222 | 7EF8C1191D0668AE00D6B608 /* CoreGraphics.framework */, 223 | 85693C4A007911B254E14E08 /* libPods.a */, 224 | ); 225 | name = Frameworks; 226 | sourceTree = ""; 227 | }; 228 | /* End PBXGroup section */ 229 | 230 | /* Begin PBXNativeTarget section */ 231 | 7E1B00C81CF998A4004FEE48 /* StarbucksCreditCardInteractionDemo */ = { 232 | isa = PBXNativeTarget; 233 | buildConfigurationList = 7E1B00E01CF998A4004FEE48 /* Build configuration list for PBXNativeTarget "StarbucksCreditCardInteractionDemo" */; 234 | buildPhases = ( 235 | FA913B25DE17A780265E4180 /* Check Pods Manifest.lock */, 236 | 7E1B00C51CF998A4004FEE48 /* Sources */, 237 | 7E1B00C61CF998A4004FEE48 /* Frameworks */, 238 | 7E1B00C71CF998A4004FEE48 /* Resources */, 239 | 14EB7C866A8C25D22D0FED37 /* Embed Pods Frameworks */, 240 | 6F457D8B48C43DCAC882B06D /* Copy Pods Resources */, 241 | ); 242 | buildRules = ( 243 | ); 244 | dependencies = ( 245 | ); 246 | name = StarbucksCreditCardInteractionDemo; 247 | productName = StarbucksCreditCardInteractionDemo; 248 | productReference = 7E1B00C91CF998A4004FEE48 /* StarbucksCreditCardInteractionDemo.app */; 249 | productType = "com.apple.product-type.application"; 250 | }; 251 | /* End PBXNativeTarget section */ 252 | 253 | /* Begin PBXProject section */ 254 | 7E1B00C11CF998A4004FEE48 /* Project object */ = { 255 | isa = PBXProject; 256 | attributes = { 257 | LastUpgradeCheck = 0730; 258 | ORGANIZATIONNAME = "颜建文"; 259 | TargetAttributes = { 260 | 7E1B00C81CF998A4004FEE48 = { 261 | CreatedOnToolsVersion = 7.3; 262 | }; 263 | }; 264 | }; 265 | buildConfigurationList = 7E1B00C41CF998A4004FEE48 /* Build configuration list for PBXProject "StarbucksCreditCardInteractionDemo" */; 266 | compatibilityVersion = "Xcode 3.2"; 267 | developmentRegion = English; 268 | hasScannedForEncodings = 0; 269 | knownRegions = ( 270 | en, 271 | Base, 272 | ); 273 | mainGroup = 7E1B00C01CF998A4004FEE48; 274 | productRefGroup = 7E1B00CA1CF998A4004FEE48 /* Products */; 275 | projectDirPath = ""; 276 | projectRoot = ""; 277 | targets = ( 278 | 7E1B00C81CF998A4004FEE48 /* StarbucksCreditCardInteractionDemo */, 279 | ); 280 | }; 281 | /* End PBXProject section */ 282 | 283 | /* Begin PBXResourcesBuildPhase section */ 284 | 7E1B00C71CF998A4004FEE48 /* Resources */ = { 285 | isa = PBXResourcesBuildPhase; 286 | buildActionMask = 2147483647; 287 | files = ( 288 | 7E1B00DC1CF998A4004FEE48 /* LaunchScreen.storyboard in Resources */, 289 | 7E1B00D91CF998A4004FEE48 /* Assets.xcassets in Resources */, 290 | 7E1B00D71CF998A4004FEE48 /* Main.storyboard in Resources */, 291 | 7E1B011A1CF9D230004FEE48 /* Pay.storyboard in Resources */, 292 | ); 293 | runOnlyForDeploymentPostprocessing = 0; 294 | }; 295 | /* End PBXResourcesBuildPhase section */ 296 | 297 | /* Begin PBXShellScriptBuildPhase section */ 298 | 14EB7C866A8C25D22D0FED37 /* Embed Pods Frameworks */ = { 299 | isa = PBXShellScriptBuildPhase; 300 | buildActionMask = 2147483647; 301 | files = ( 302 | ); 303 | inputPaths = ( 304 | ); 305 | name = "Embed Pods Frameworks"; 306 | outputPaths = ( 307 | ); 308 | runOnlyForDeploymentPostprocessing = 0; 309 | shellPath = /bin/sh; 310 | shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods/Pods-frameworks.sh\"\n"; 311 | showEnvVarsInLog = 0; 312 | }; 313 | 6F457D8B48C43DCAC882B06D /* Copy Pods Resources */ = { 314 | isa = PBXShellScriptBuildPhase; 315 | buildActionMask = 2147483647; 316 | files = ( 317 | ); 318 | inputPaths = ( 319 | ); 320 | name = "Copy Pods Resources"; 321 | outputPaths = ( 322 | ); 323 | runOnlyForDeploymentPostprocessing = 0; 324 | shellPath = /bin/sh; 325 | shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods/Pods-resources.sh\"\n"; 326 | showEnvVarsInLog = 0; 327 | }; 328 | FA913B25DE17A780265E4180 /* Check Pods Manifest.lock */ = { 329 | isa = PBXShellScriptBuildPhase; 330 | buildActionMask = 2147483647; 331 | files = ( 332 | ); 333 | inputPaths = ( 334 | ); 335 | name = "Check Pods Manifest.lock"; 336 | outputPaths = ( 337 | ); 338 | runOnlyForDeploymentPostprocessing = 0; 339 | shellPath = /bin/sh; 340 | shellScript = "diff \"${PODS_ROOT}/../Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [[ $? != 0 ]] ; then\n cat << EOM\nerror: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\nEOM\n exit 1\nfi\n"; 341 | showEnvVarsInLog = 0; 342 | }; 343 | /* End PBXShellScriptBuildPhase section */ 344 | 345 | /* Begin PBXSourcesBuildPhase section */ 346 | 7E1B00C51CF998A4004FEE48 /* Sources */ = { 347 | isa = PBXSourcesBuildPhase; 348 | buildActionMask = 2147483647; 349 | files = ( 350 | 7E1B01131CF9A201004FEE48 /* TopBarIndicatorView.m in Sources */, 351 | 7E1B01211CFB08B3004FEE48 /* iCarousel.m in Sources */, 352 | 7E1B011D1CF9D25A004FEE48 /* PayViewController.m in Sources */, 353 | 7E9CB9861D001C6B00B5F4C3 /* YanBannerViewCell.m in Sources */, 354 | 7E1B01171CF9A201004FEE48 /* UIColor+Fade.m in Sources */, 355 | 7E1B01141CF9A201004FEE48 /* TopBarPageController.m in Sources */, 356 | 7E1B00D41CF998A4004FEE48 /* MainViewController.m in Sources */, 357 | 7EF8C08F1D056AD400D6B608 /* PaySuccessViewController.m in Sources */, 358 | 7E1B00D11CF998A4004FEE48 /* AppDelegate.m in Sources */, 359 | 7E1B01161CF9A201004FEE48 /* TopBarView.m in Sources */, 360 | 7E9CB9851D001C6B00B5F4C3 /* YanBannerView.m in Sources */, 361 | 7E1B01251CFC861E004FEE48 /* PayCardInfoViewController.m in Sources */, 362 | 7E9CB98A1D01AFE200B5F4C3 /* SpecialKeyBoardView.m in Sources */, 363 | 7E1B00CE1CF998A4004FEE48 /* main.m in Sources */, 364 | 7E1B01151CF9A201004FEE48 /* TopBarView+ExpandItem.m in Sources */, 365 | 7E9CB97F1CFEA53500B5F4C3 /* UIView+PopAnimation.m in Sources */, 366 | ); 367 | runOnlyForDeploymentPostprocessing = 0; 368 | }; 369 | /* End PBXSourcesBuildPhase section */ 370 | 371 | /* Begin PBXVariantGroup section */ 372 | 7E1B00D51CF998A4004FEE48 /* Main.storyboard */ = { 373 | isa = PBXVariantGroup; 374 | children = ( 375 | 7E1B00D61CF998A4004FEE48 /* Base */, 376 | ); 377 | name = Main.storyboard; 378 | sourceTree = ""; 379 | }; 380 | 7E1B00DA1CF998A4004FEE48 /* LaunchScreen.storyboard */ = { 381 | isa = PBXVariantGroup; 382 | children = ( 383 | 7E1B00DB1CF998A4004FEE48 /* Base */, 384 | ); 385 | name = LaunchScreen.storyboard; 386 | sourceTree = ""; 387 | }; 388 | 7E1B01181CF9D22F004FEE48 /* Pay.storyboard */ = { 389 | isa = PBXVariantGroup; 390 | children = ( 391 | 7E1B01191CF9D230004FEE48 /* Base */, 392 | ); 393 | name = Pay.storyboard; 394 | sourceTree = ""; 395 | }; 396 | /* End PBXVariantGroup section */ 397 | 398 | /* Begin XCBuildConfiguration section */ 399 | 7E1B00DE1CF998A4004FEE48 /* Debug */ = { 400 | isa = XCBuildConfiguration; 401 | buildSettings = { 402 | ALWAYS_SEARCH_USER_PATHS = NO; 403 | CLANG_ANALYZER_NONNULL = YES; 404 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 405 | CLANG_CXX_LIBRARY = "libc++"; 406 | CLANG_ENABLE_MODULES = YES; 407 | CLANG_ENABLE_OBJC_ARC = YES; 408 | CLANG_WARN_BOOL_CONVERSION = YES; 409 | CLANG_WARN_CONSTANT_CONVERSION = YES; 410 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 411 | CLANG_WARN_EMPTY_BODY = YES; 412 | CLANG_WARN_ENUM_CONVERSION = YES; 413 | CLANG_WARN_INT_CONVERSION = YES; 414 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 415 | CLANG_WARN_UNREACHABLE_CODE = YES; 416 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 417 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 418 | COPY_PHASE_STRIP = NO; 419 | DEBUG_INFORMATION_FORMAT = dwarf; 420 | ENABLE_STRICT_OBJC_MSGSEND = YES; 421 | ENABLE_TESTABILITY = YES; 422 | GCC_C_LANGUAGE_STANDARD = gnu99; 423 | GCC_DYNAMIC_NO_PIC = NO; 424 | GCC_NO_COMMON_BLOCKS = YES; 425 | GCC_OPTIMIZATION_LEVEL = 0; 426 | GCC_PREPROCESSOR_DEFINITIONS = ( 427 | "DEBUG=1", 428 | "$(inherited)", 429 | ); 430 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 431 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 432 | GCC_WARN_UNDECLARED_SELECTOR = YES; 433 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 434 | GCC_WARN_UNUSED_FUNCTION = YES; 435 | GCC_WARN_UNUSED_VARIABLE = YES; 436 | IPHONEOS_DEPLOYMENT_TARGET = 9.3; 437 | MTL_ENABLE_DEBUG_INFO = YES; 438 | ONLY_ACTIVE_ARCH = YES; 439 | SDKROOT = iphoneos; 440 | }; 441 | name = Debug; 442 | }; 443 | 7E1B00DF1CF998A4004FEE48 /* Release */ = { 444 | isa = XCBuildConfiguration; 445 | buildSettings = { 446 | ALWAYS_SEARCH_USER_PATHS = NO; 447 | CLANG_ANALYZER_NONNULL = YES; 448 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 449 | CLANG_CXX_LIBRARY = "libc++"; 450 | CLANG_ENABLE_MODULES = YES; 451 | CLANG_ENABLE_OBJC_ARC = YES; 452 | CLANG_WARN_BOOL_CONVERSION = YES; 453 | CLANG_WARN_CONSTANT_CONVERSION = YES; 454 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 455 | CLANG_WARN_EMPTY_BODY = YES; 456 | CLANG_WARN_ENUM_CONVERSION = YES; 457 | CLANG_WARN_INT_CONVERSION = YES; 458 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 459 | CLANG_WARN_UNREACHABLE_CODE = YES; 460 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 461 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 462 | COPY_PHASE_STRIP = NO; 463 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 464 | ENABLE_NS_ASSERTIONS = NO; 465 | ENABLE_STRICT_OBJC_MSGSEND = YES; 466 | GCC_C_LANGUAGE_STANDARD = gnu99; 467 | GCC_NO_COMMON_BLOCKS = YES; 468 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 469 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 470 | GCC_WARN_UNDECLARED_SELECTOR = YES; 471 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 472 | GCC_WARN_UNUSED_FUNCTION = YES; 473 | GCC_WARN_UNUSED_VARIABLE = YES; 474 | IPHONEOS_DEPLOYMENT_TARGET = 9.3; 475 | MTL_ENABLE_DEBUG_INFO = NO; 476 | SDKROOT = iphoneos; 477 | VALIDATE_PRODUCT = YES; 478 | }; 479 | name = Release; 480 | }; 481 | 7E1B00E11CF998A4004FEE48 /* Debug */ = { 482 | isa = XCBuildConfiguration; 483 | baseConfigurationReference = 9E3F595628878A50CC7DBA9E /* Pods.debug.xcconfig */; 484 | buildSettings = { 485 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 486 | INFOPLIST_FILE = StarbucksCreditCardInteractionDemo/Info.plist; 487 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 488 | PRODUCT_BUNDLE_IDENTIFIER = org.yanjw.StarbucksPay; 489 | PRODUCT_NAME = "$(TARGET_NAME)"; 490 | }; 491 | name = Debug; 492 | }; 493 | 7E1B00E21CF998A4004FEE48 /* Release */ = { 494 | isa = XCBuildConfiguration; 495 | baseConfigurationReference = DD7F2462AD94BF54466DEAD2 /* Pods.release.xcconfig */; 496 | buildSettings = { 497 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 498 | INFOPLIST_FILE = StarbucksCreditCardInteractionDemo/Info.plist; 499 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 500 | PRODUCT_BUNDLE_IDENTIFIER = org.yanjw.StarbucksPay; 501 | PRODUCT_NAME = "$(TARGET_NAME)"; 502 | }; 503 | name = Release; 504 | }; 505 | /* End XCBuildConfiguration section */ 506 | 507 | /* Begin XCConfigurationList section */ 508 | 7E1B00C41CF998A4004FEE48 /* Build configuration list for PBXProject "StarbucksCreditCardInteractionDemo" */ = { 509 | isa = XCConfigurationList; 510 | buildConfigurations = ( 511 | 7E1B00DE1CF998A4004FEE48 /* Debug */, 512 | 7E1B00DF1CF998A4004FEE48 /* Release */, 513 | ); 514 | defaultConfigurationIsVisible = 0; 515 | defaultConfigurationName = Release; 516 | }; 517 | 7E1B00E01CF998A4004FEE48 /* Build configuration list for PBXNativeTarget "StarbucksCreditCardInteractionDemo" */ = { 518 | isa = XCConfigurationList; 519 | buildConfigurations = ( 520 | 7E1B00E11CF998A4004FEE48 /* Debug */, 521 | 7E1B00E21CF998A4004FEE48 /* Release */, 522 | ); 523 | defaultConfigurationIsVisible = 0; 524 | defaultConfigurationName = Release; 525 | }; 526 | /* End XCConfigurationList section */ 527 | }; 528 | rootObject = 7E1B00C11CF998A4004FEE48 /* Project object */; 529 | } 530 | -------------------------------------------------------------------------------- /1.StarbucksCreditCardInteractionDemo/StarbucksCreditCardInteractionDemo.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /1.StarbucksCreditCardInteractionDemo/StarbucksCreditCardInteractionDemo.xcodeproj/project.xcworkspace/xcuserdata/yanjianwen.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JianwenYan/iOSFunningAnimation/a93d4e15e59b9fd396b083d4ec69da0179c934bd/1.StarbucksCreditCardInteractionDemo/StarbucksCreditCardInteractionDemo.xcodeproj/project.xcworkspace/xcuserdata/yanjianwen.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /1.StarbucksCreditCardInteractionDemo/StarbucksCreditCardInteractionDemo.xcodeproj/xcuserdata/yanjianwen.xcuserdatad/xcschemes/StarbucksCreditCardInteractionDemo.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 | -------------------------------------------------------------------------------- /1.StarbucksCreditCardInteractionDemo/StarbucksCreditCardInteractionDemo.xcodeproj/xcuserdata/yanjianwen.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | StarbucksCreditCardInteractionDemo.xcscheme 8 | 9 | orderHint 10 | 0 11 | 12 | 13 | SuppressBuildableAutocreation 14 | 15 | 7E1B00C81CF998A4004FEE48 16 | 17 | primary 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /1.StarbucksCreditCardInteractionDemo/StarbucksCreditCardInteractionDemo/AppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.h 3 | // StarbucksCreditCardInteractionDemo 4 | // 5 | // Created by 颜建文 on 16/5/28. 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 | -------------------------------------------------------------------------------- /1.StarbucksCreditCardInteractionDemo/StarbucksCreditCardInteractionDemo/AppDelegate.m: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.m 3 | // StarbucksCreditCardInteractionDemo 4 | // 5 | // Created by 颜建文 on 16/5/28. 6 | // Copyright © 2016年 颜建文. All rights reserved. 7 | // 8 | 9 | #import "AppDelegate.h" 10 | #import 11 | #import "SpecialKeyBoardView.h" 12 | 13 | @interface AppDelegate () 14 | 15 | @end 16 | 17 | @implementation AppDelegate 18 | 19 | 20 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { 21 | // Override point for customization after application launch. 22 | 23 | IQKeyboardManager *manager = [IQKeyboardManager sharedManager]; 24 | manager.enable = YES; 25 | manager.shouldResignOnTouchOutside = YES; 26 | manager.shouldToolbarUsesTextFieldTintColor = YES; 27 | manager.enableAutoToolbar = YES; 28 | [manager considerToolbarPreviousNextInViewClass:[SpecialKeyBoardView class]]; 29 | 30 | return YES; 31 | } 32 | 33 | - (void)applicationWillResignActive:(UIApplication *)application { 34 | // 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. 35 | // 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. 36 | } 37 | 38 | - (void)applicationDidEnterBackground:(UIApplication *)application { 39 | // 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. 40 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 41 | } 42 | 43 | - (void)applicationWillEnterForeground:(UIApplication *)application { 44 | // 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. 45 | } 46 | 47 | - (void)applicationDidBecomeActive:(UIApplication *)application { 48 | // 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. 49 | } 50 | 51 | - (void)applicationWillTerminate:(UIApplication *)application { 52 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 53 | } 54 | 55 | @end 56 | -------------------------------------------------------------------------------- /1.StarbucksCreditCardInteractionDemo/StarbucksCreditCardInteractionDemo/Assets.xcassets/AppIcon.appiconset/120 - iPhone.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JianwenYan/iOSFunningAnimation/a93d4e15e59b9fd396b083d4ec69da0179c934bd/1.StarbucksCreditCardInteractionDemo/StarbucksCreditCardInteractionDemo/Assets.xcassets/AppIcon.appiconset/120 - iPhone.png -------------------------------------------------------------------------------- /1.StarbucksCreditCardInteractionDemo/StarbucksCreditCardInteractionDemo/Assets.xcassets/AppIcon.appiconset/120 - iPhone@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JianwenYan/iOSFunningAnimation/a93d4e15e59b9fd396b083d4ec69da0179c934bd/1.StarbucksCreditCardInteractionDemo/StarbucksCreditCardInteractionDemo/Assets.xcassets/AppIcon.appiconset/120 - iPhone@3x.png -------------------------------------------------------------------------------- /1.StarbucksCreditCardInteractionDemo/StarbucksCreditCardInteractionDemo/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 | "size" : "60x60", 25 | "idiom" : "iphone", 26 | "filename" : "120 - iPhone.png", 27 | "scale" : "2x" 28 | }, 29 | { 30 | "size" : "60x60", 31 | "idiom" : "iphone", 32 | "filename" : "120 - iPhone@3x.png", 33 | "scale" : "3x" 34 | } 35 | ], 36 | "info" : { 37 | "version" : 1, 38 | "author" : "xcode" 39 | } 40 | } -------------------------------------------------------------------------------- /1.StarbucksCreditCardInteractionDemo/StarbucksCreditCardInteractionDemo/Assets.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "version" : 1, 4 | "author" : "xcode" 5 | } 6 | } -------------------------------------------------------------------------------- /1.StarbucksCreditCardInteractionDemo/StarbucksCreditCardInteractionDemo/Assets.xcassets/apple_pay.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "apple pay.png", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "filename" : "apple pay@2x.png", 11 | "scale" : "2x" 12 | }, 13 | { 14 | "idiom" : "universal", 15 | "filename" : "apple pay@3x.png", 16 | "scale" : "3x" 17 | } 18 | ], 19 | "info" : { 20 | "version" : 1, 21 | "author" : "xcode" 22 | } 23 | } -------------------------------------------------------------------------------- /1.StarbucksCreditCardInteractionDemo/StarbucksCreditCardInteractionDemo/Assets.xcassets/apple_pay.imageset/apple pay.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JianwenYan/iOSFunningAnimation/a93d4e15e59b9fd396b083d4ec69da0179c934bd/1.StarbucksCreditCardInteractionDemo/StarbucksCreditCardInteractionDemo/Assets.xcassets/apple_pay.imageset/apple pay.png -------------------------------------------------------------------------------- /1.StarbucksCreditCardInteractionDemo/StarbucksCreditCardInteractionDemo/Assets.xcassets/apple_pay.imageset/apple pay@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JianwenYan/iOSFunningAnimation/a93d4e15e59b9fd396b083d4ec69da0179c934bd/1.StarbucksCreditCardInteractionDemo/StarbucksCreditCardInteractionDemo/Assets.xcassets/apple_pay.imageset/apple pay@2x.png -------------------------------------------------------------------------------- /1.StarbucksCreditCardInteractionDemo/StarbucksCreditCardInteractionDemo/Assets.xcassets/apple_pay.imageset/apple pay@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JianwenYan/iOSFunningAnimation/a93d4e15e59b9fd396b083d4ec69da0179c934bd/1.StarbucksCreditCardInteractionDemo/StarbucksCreditCardInteractionDemo/Assets.xcassets/apple_pay.imageset/apple pay@3x.png -------------------------------------------------------------------------------- /1.StarbucksCreditCardInteractionDemo/StarbucksCreditCardInteractionDemo/Assets.xcassets/apple_pay_large.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "apple pay_large.png", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "filename" : "apple pay_large@2x.png", 11 | "scale" : "2x" 12 | }, 13 | { 14 | "idiom" : "universal", 15 | "filename" : "apple pay_large@3x.png", 16 | "scale" : "3x" 17 | } 18 | ], 19 | "info" : { 20 | "version" : 1, 21 | "author" : "xcode" 22 | } 23 | } -------------------------------------------------------------------------------- /1.StarbucksCreditCardInteractionDemo/StarbucksCreditCardInteractionDemo/Assets.xcassets/apple_pay_large.imageset/apple pay_large.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JianwenYan/iOSFunningAnimation/a93d4e15e59b9fd396b083d4ec69da0179c934bd/1.StarbucksCreditCardInteractionDemo/StarbucksCreditCardInteractionDemo/Assets.xcassets/apple_pay_large.imageset/apple pay_large.png -------------------------------------------------------------------------------- /1.StarbucksCreditCardInteractionDemo/StarbucksCreditCardInteractionDemo/Assets.xcassets/apple_pay_large.imageset/apple pay_large@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JianwenYan/iOSFunningAnimation/a93d4e15e59b9fd396b083d4ec69da0179c934bd/1.StarbucksCreditCardInteractionDemo/StarbucksCreditCardInteractionDemo/Assets.xcassets/apple_pay_large.imageset/apple pay_large@2x.png -------------------------------------------------------------------------------- /1.StarbucksCreditCardInteractionDemo/StarbucksCreditCardInteractionDemo/Assets.xcassets/apple_pay_large.imageset/apple pay_large@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JianwenYan/iOSFunningAnimation/a93d4e15e59b9fd396b083d4ec69da0179c934bd/1.StarbucksCreditCardInteractionDemo/StarbucksCreditCardInteractionDemo/Assets.xcassets/apple_pay_large.imageset/apple pay_large@3x.png -------------------------------------------------------------------------------- /1.StarbucksCreditCardInteractionDemo/StarbucksCreditCardInteractionDemo/Assets.xcassets/background_text.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "Mask Copy.png", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "filename" : "Mask Copy@2x.png", 11 | "scale" : "2x" 12 | }, 13 | { 14 | "idiom" : "universal", 15 | "filename" : "Mask Copy@3x.png", 16 | "scale" : "3x" 17 | } 18 | ], 19 | "info" : { 20 | "version" : 1, 21 | "author" : "xcode" 22 | } 23 | } -------------------------------------------------------------------------------- /1.StarbucksCreditCardInteractionDemo/StarbucksCreditCardInteractionDemo/Assets.xcassets/background_text.imageset/Mask Copy.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JianwenYan/iOSFunningAnimation/a93d4e15e59b9fd396b083d4ec69da0179c934bd/1.StarbucksCreditCardInteractionDemo/StarbucksCreditCardInteractionDemo/Assets.xcassets/background_text.imageset/Mask Copy.png -------------------------------------------------------------------------------- /1.StarbucksCreditCardInteractionDemo/StarbucksCreditCardInteractionDemo/Assets.xcassets/background_text.imageset/Mask Copy@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JianwenYan/iOSFunningAnimation/a93d4e15e59b9fd396b083d4ec69da0179c934bd/1.StarbucksCreditCardInteractionDemo/StarbucksCreditCardInteractionDemo/Assets.xcassets/background_text.imageset/Mask Copy@2x.png -------------------------------------------------------------------------------- /1.StarbucksCreditCardInteractionDemo/StarbucksCreditCardInteractionDemo/Assets.xcassets/background_text.imageset/Mask Copy@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JianwenYan/iOSFunningAnimation/a93d4e15e59b9fd396b083d4ec69da0179c934bd/1.StarbucksCreditCardInteractionDemo/StarbucksCreditCardInteractionDemo/Assets.xcassets/background_text.imageset/Mask Copy@3x.png -------------------------------------------------------------------------------- /1.StarbucksCreditCardInteractionDemo/StarbucksCreditCardInteractionDemo/Assets.xcassets/combined.imageset/Combined Shape.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JianwenYan/iOSFunningAnimation/a93d4e15e59b9fd396b083d4ec69da0179c934bd/1.StarbucksCreditCardInteractionDemo/StarbucksCreditCardInteractionDemo/Assets.xcassets/combined.imageset/Combined Shape.png -------------------------------------------------------------------------------- /1.StarbucksCreditCardInteractionDemo/StarbucksCreditCardInteractionDemo/Assets.xcassets/combined.imageset/Combined Shape@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JianwenYan/iOSFunningAnimation/a93d4e15e59b9fd396b083d4ec69da0179c934bd/1.StarbucksCreditCardInteractionDemo/StarbucksCreditCardInteractionDemo/Assets.xcassets/combined.imageset/Combined Shape@2x.png -------------------------------------------------------------------------------- /1.StarbucksCreditCardInteractionDemo/StarbucksCreditCardInteractionDemo/Assets.xcassets/combined.imageset/Combined Shape@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JianwenYan/iOSFunningAnimation/a93d4e15e59b9fd396b083d4ec69da0179c934bd/1.StarbucksCreditCardInteractionDemo/StarbucksCreditCardInteractionDemo/Assets.xcassets/combined.imageset/Combined Shape@3x.png -------------------------------------------------------------------------------- /1.StarbucksCreditCardInteractionDemo/StarbucksCreditCardInteractionDemo/Assets.xcassets/combined.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "Combined Shape.png", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "filename" : "Combined Shape@2x.png", 11 | "scale" : "2x" 12 | }, 13 | { 14 | "idiom" : "universal", 15 | "filename" : "Combined Shape@3x.png", 16 | "scale" : "3x" 17 | } 18 | ], 19 | "info" : { 20 | "version" : 1, 21 | "author" : "xcode" 22 | } 23 | } -------------------------------------------------------------------------------- /1.StarbucksCreditCardInteractionDemo/StarbucksCreditCardInteractionDemo/Assets.xcassets/cup.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "Cup.png", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "filename" : "Cup@2x.png", 11 | "scale" : "2x" 12 | }, 13 | { 14 | "idiom" : "universal", 15 | "filename" : "Cup@3x.png", 16 | "scale" : "3x" 17 | } 18 | ], 19 | "info" : { 20 | "version" : 1, 21 | "author" : "xcode" 22 | } 23 | } -------------------------------------------------------------------------------- /1.StarbucksCreditCardInteractionDemo/StarbucksCreditCardInteractionDemo/Assets.xcassets/cup.imageset/Cup.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JianwenYan/iOSFunningAnimation/a93d4e15e59b9fd396b083d4ec69da0179c934bd/1.StarbucksCreditCardInteractionDemo/StarbucksCreditCardInteractionDemo/Assets.xcassets/cup.imageset/Cup.png -------------------------------------------------------------------------------- /1.StarbucksCreditCardInteractionDemo/StarbucksCreditCardInteractionDemo/Assets.xcassets/cup.imageset/Cup@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JianwenYan/iOSFunningAnimation/a93d4e15e59b9fd396b083d4ec69da0179c934bd/1.StarbucksCreditCardInteractionDemo/StarbucksCreditCardInteractionDemo/Assets.xcassets/cup.imageset/Cup@2x.png -------------------------------------------------------------------------------- /1.StarbucksCreditCardInteractionDemo/StarbucksCreditCardInteractionDemo/Assets.xcassets/cup.imageset/Cup@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JianwenYan/iOSFunningAnimation/a93d4e15e59b9fd396b083d4ec69da0179c934bd/1.StarbucksCreditCardInteractionDemo/StarbucksCreditCardInteractionDemo/Assets.xcassets/cup.imageset/Cup@3x.png -------------------------------------------------------------------------------- /1.StarbucksCreditCardInteractionDemo/StarbucksCreditCardInteractionDemo/Assets.xcassets/master_card.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "master.png", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "filename" : "master@2x.png", 11 | "scale" : "2x" 12 | }, 13 | { 14 | "idiom" : "universal", 15 | "filename" : "master@3x.png", 16 | "scale" : "3x" 17 | } 18 | ], 19 | "info" : { 20 | "version" : 1, 21 | "author" : "xcode" 22 | } 23 | } -------------------------------------------------------------------------------- /1.StarbucksCreditCardInteractionDemo/StarbucksCreditCardInteractionDemo/Assets.xcassets/master_card.imageset/master.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JianwenYan/iOSFunningAnimation/a93d4e15e59b9fd396b083d4ec69da0179c934bd/1.StarbucksCreditCardInteractionDemo/StarbucksCreditCardInteractionDemo/Assets.xcassets/master_card.imageset/master.png -------------------------------------------------------------------------------- /1.StarbucksCreditCardInteractionDemo/StarbucksCreditCardInteractionDemo/Assets.xcassets/master_card.imageset/master@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JianwenYan/iOSFunningAnimation/a93d4e15e59b9fd396b083d4ec69da0179c934bd/1.StarbucksCreditCardInteractionDemo/StarbucksCreditCardInteractionDemo/Assets.xcassets/master_card.imageset/master@2x.png -------------------------------------------------------------------------------- /1.StarbucksCreditCardInteractionDemo/StarbucksCreditCardInteractionDemo/Assets.xcassets/master_card.imageset/master@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JianwenYan/iOSFunningAnimation/a93d4e15e59b9fd396b083d4ec69da0179c934bd/1.StarbucksCreditCardInteractionDemo/StarbucksCreditCardInteractionDemo/Assets.xcassets/master_card.imageset/master@3x.png -------------------------------------------------------------------------------- /1.StarbucksCreditCardInteractionDemo/StarbucksCreditCardInteractionDemo/Assets.xcassets/master_large.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "master_large.png", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "filename" : "master_large@2x.png", 11 | "scale" : "2x" 12 | }, 13 | { 14 | "idiom" : "universal", 15 | "filename" : "master_large@3x.png", 16 | "scale" : "3x" 17 | } 18 | ], 19 | "info" : { 20 | "version" : 1, 21 | "author" : "xcode" 22 | } 23 | } -------------------------------------------------------------------------------- /1.StarbucksCreditCardInteractionDemo/StarbucksCreditCardInteractionDemo/Assets.xcassets/master_large.imageset/master_large.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JianwenYan/iOSFunningAnimation/a93d4e15e59b9fd396b083d4ec69da0179c934bd/1.StarbucksCreditCardInteractionDemo/StarbucksCreditCardInteractionDemo/Assets.xcassets/master_large.imageset/master_large.png -------------------------------------------------------------------------------- /1.StarbucksCreditCardInteractionDemo/StarbucksCreditCardInteractionDemo/Assets.xcassets/master_large.imageset/master_large@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JianwenYan/iOSFunningAnimation/a93d4e15e59b9fd396b083d4ec69da0179c934bd/1.StarbucksCreditCardInteractionDemo/StarbucksCreditCardInteractionDemo/Assets.xcassets/master_large.imageset/master_large@2x.png -------------------------------------------------------------------------------- /1.StarbucksCreditCardInteractionDemo/StarbucksCreditCardInteractionDemo/Assets.xcassets/master_large.imageset/master_large@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JianwenYan/iOSFunningAnimation/a93d4e15e59b9fd396b083d4ec69da0179c934bd/1.StarbucksCreditCardInteractionDemo/StarbucksCreditCardInteractionDemo/Assets.xcassets/master_large.imageset/master_large@3x.png -------------------------------------------------------------------------------- /1.StarbucksCreditCardInteractionDemo/StarbucksCreditCardInteractionDemo/Assets.xcassets/oval.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "Oval 46.png", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "filename" : "Oval 46@2x.png", 11 | "scale" : "2x" 12 | }, 13 | { 14 | "idiom" : "universal", 15 | "filename" : "Oval 46@3x.png", 16 | "scale" : "3x" 17 | } 18 | ], 19 | "info" : { 20 | "version" : 1, 21 | "author" : "xcode" 22 | } 23 | } -------------------------------------------------------------------------------- /1.StarbucksCreditCardInteractionDemo/StarbucksCreditCardInteractionDemo/Assets.xcassets/oval.imageset/Oval 46.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JianwenYan/iOSFunningAnimation/a93d4e15e59b9fd396b083d4ec69da0179c934bd/1.StarbucksCreditCardInteractionDemo/StarbucksCreditCardInteractionDemo/Assets.xcassets/oval.imageset/Oval 46.png -------------------------------------------------------------------------------- /1.StarbucksCreditCardInteractionDemo/StarbucksCreditCardInteractionDemo/Assets.xcassets/oval.imageset/Oval 46@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JianwenYan/iOSFunningAnimation/a93d4e15e59b9fd396b083d4ec69da0179c934bd/1.StarbucksCreditCardInteractionDemo/StarbucksCreditCardInteractionDemo/Assets.xcassets/oval.imageset/Oval 46@2x.png -------------------------------------------------------------------------------- /1.StarbucksCreditCardInteractionDemo/StarbucksCreditCardInteractionDemo/Assets.xcassets/oval.imageset/Oval 46@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JianwenYan/iOSFunningAnimation/a93d4e15e59b9fd396b083d4ec69da0179c934bd/1.StarbucksCreditCardInteractionDemo/StarbucksCreditCardInteractionDemo/Assets.xcassets/oval.imageset/Oval 46@3x.png -------------------------------------------------------------------------------- /1.StarbucksCreditCardInteractionDemo/StarbucksCreditCardInteractionDemo/Assets.xcassets/starbucks_card.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "starbucks-card-png-flexprint-starbucks-gift-card.png", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "filename" : "starbucks-card-png-flexprint-starbucks-gift-card@2x.png", 11 | "scale" : "2x" 12 | }, 13 | { 14 | "idiom" : "universal", 15 | "filename" : "starbucks-card-png-flexprint-starbucks-gift-card@3x.png", 16 | "scale" : "3x" 17 | } 18 | ], 19 | "info" : { 20 | "version" : 1, 21 | "author" : "xcode" 22 | } 23 | } -------------------------------------------------------------------------------- /1.StarbucksCreditCardInteractionDemo/StarbucksCreditCardInteractionDemo/Assets.xcassets/starbucks_card.imageset/starbucks-card-png-flexprint-starbucks-gift-card.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JianwenYan/iOSFunningAnimation/a93d4e15e59b9fd396b083d4ec69da0179c934bd/1.StarbucksCreditCardInteractionDemo/StarbucksCreditCardInteractionDemo/Assets.xcassets/starbucks_card.imageset/starbucks-card-png-flexprint-starbucks-gift-card.png -------------------------------------------------------------------------------- /1.StarbucksCreditCardInteractionDemo/StarbucksCreditCardInteractionDemo/Assets.xcassets/starbucks_card.imageset/starbucks-card-png-flexprint-starbucks-gift-card@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JianwenYan/iOSFunningAnimation/a93d4e15e59b9fd396b083d4ec69da0179c934bd/1.StarbucksCreditCardInteractionDemo/StarbucksCreditCardInteractionDemo/Assets.xcassets/starbucks_card.imageset/starbucks-card-png-flexprint-starbucks-gift-card@2x.png -------------------------------------------------------------------------------- /1.StarbucksCreditCardInteractionDemo/StarbucksCreditCardInteractionDemo/Assets.xcassets/starbucks_card.imageset/starbucks-card-png-flexprint-starbucks-gift-card@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JianwenYan/iOSFunningAnimation/a93d4e15e59b9fd396b083d4ec69da0179c934bd/1.StarbucksCreditCardInteractionDemo/StarbucksCreditCardInteractionDemo/Assets.xcassets/starbucks_card.imageset/starbucks-card-png-flexprint-starbucks-gift-card@3x.png -------------------------------------------------------------------------------- /1.StarbucksCreditCardInteractionDemo/StarbucksCreditCardInteractionDemo/Assets.xcassets/visa_card.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "visa.png", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "filename" : "visa@2x.png", 11 | "scale" : "2x" 12 | }, 13 | { 14 | "idiom" : "universal", 15 | "filename" : "visa@3x.png", 16 | "scale" : "3x" 17 | } 18 | ], 19 | "info" : { 20 | "version" : 1, 21 | "author" : "xcode" 22 | } 23 | } -------------------------------------------------------------------------------- /1.StarbucksCreditCardInteractionDemo/StarbucksCreditCardInteractionDemo/Assets.xcassets/visa_card.imageset/visa.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JianwenYan/iOSFunningAnimation/a93d4e15e59b9fd396b083d4ec69da0179c934bd/1.StarbucksCreditCardInteractionDemo/StarbucksCreditCardInteractionDemo/Assets.xcassets/visa_card.imageset/visa.png -------------------------------------------------------------------------------- /1.StarbucksCreditCardInteractionDemo/StarbucksCreditCardInteractionDemo/Assets.xcassets/visa_card.imageset/visa@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JianwenYan/iOSFunningAnimation/a93d4e15e59b9fd396b083d4ec69da0179c934bd/1.StarbucksCreditCardInteractionDemo/StarbucksCreditCardInteractionDemo/Assets.xcassets/visa_card.imageset/visa@2x.png -------------------------------------------------------------------------------- /1.StarbucksCreditCardInteractionDemo/StarbucksCreditCardInteractionDemo/Assets.xcassets/visa_card.imageset/visa@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JianwenYan/iOSFunningAnimation/a93d4e15e59b9fd396b083d4ec69da0179c934bd/1.StarbucksCreditCardInteractionDemo/StarbucksCreditCardInteractionDemo/Assets.xcassets/visa_card.imageset/visa@3x.png -------------------------------------------------------------------------------- /1.StarbucksCreditCardInteractionDemo/StarbucksCreditCardInteractionDemo/Assets.xcassets/visa_large.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "visa_large.png", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "filename" : "visa_large@2x.png", 11 | "scale" : "2x" 12 | }, 13 | { 14 | "idiom" : "universal", 15 | "filename" : "visa_large@3x.png", 16 | "scale" : "3x" 17 | } 18 | ], 19 | "info" : { 20 | "version" : 1, 21 | "author" : "xcode" 22 | } 23 | } -------------------------------------------------------------------------------- /1.StarbucksCreditCardInteractionDemo/StarbucksCreditCardInteractionDemo/Assets.xcassets/visa_large.imageset/visa_large.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JianwenYan/iOSFunningAnimation/a93d4e15e59b9fd396b083d4ec69da0179c934bd/1.StarbucksCreditCardInteractionDemo/StarbucksCreditCardInteractionDemo/Assets.xcassets/visa_large.imageset/visa_large.png -------------------------------------------------------------------------------- /1.StarbucksCreditCardInteractionDemo/StarbucksCreditCardInteractionDemo/Assets.xcassets/visa_large.imageset/visa_large@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JianwenYan/iOSFunningAnimation/a93d4e15e59b9fd396b083d4ec69da0179c934bd/1.StarbucksCreditCardInteractionDemo/StarbucksCreditCardInteractionDemo/Assets.xcassets/visa_large.imageset/visa_large@2x.png -------------------------------------------------------------------------------- /1.StarbucksCreditCardInteractionDemo/StarbucksCreditCardInteractionDemo/Assets.xcassets/visa_large.imageset/visa_large@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JianwenYan/iOSFunningAnimation/a93d4e15e59b9fd396b083d4ec69da0179c934bd/1.StarbucksCreditCardInteractionDemo/StarbucksCreditCardInteractionDemo/Assets.xcassets/visa_large.imageset/visa_large@3x.png -------------------------------------------------------------------------------- /1.StarbucksCreditCardInteractionDemo/StarbucksCreditCardInteractionDemo/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 | -------------------------------------------------------------------------------- /1.StarbucksCreditCardInteractionDemo/StarbucksCreditCardInteractionDemo/Base.lproj/Main.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /1.StarbucksCreditCardInteractionDemo/StarbucksCreditCardInteractionDemo/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDisplayName 6 | StarPay 7 | CFBundleDevelopmentRegion 8 | en 9 | CFBundleExecutable 10 | $(EXECUTABLE_NAME) 11 | CFBundleIdentifier 12 | $(PRODUCT_BUNDLE_IDENTIFIER) 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 25 | LSRequiresIPhoneOS 26 | 27 | UILaunchStoryboardName 28 | LaunchScreen 29 | UIMainStoryboardFile 30 | Main 31 | UIRequiredDeviceCapabilities 32 | 33 | armv7 34 | 35 | UISupportedInterfaceOrientations 36 | 37 | UIInterfaceOrientationPortrait 38 | 39 | 40 | 41 | -------------------------------------------------------------------------------- /1.StarbucksCreditCardInteractionDemo/StarbucksCreditCardInteractionDemo/MainViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // MainViewController.h 3 | // StarbucksCreditCardInteractionDemo 4 | // 5 | // Created by 颜建文 on 16/5/28. 6 | // Copyright © 2016年 颜建文. All rights reserved. 7 | // 8 | 9 | #import "TopBarPageController.h" 10 | 11 | @interface MainViewController : TopBarPageController 12 | 13 | 14 | 15 | @end 16 | 17 | -------------------------------------------------------------------------------- /1.StarbucksCreditCardInteractionDemo/StarbucksCreditCardInteractionDemo/MainViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // MainViewController.hr.m 3 | // StarbucksCreditCardInteractionDemo 4 | // 5 | // Created by 颜建文 on 16/5/28. 6 | // Copyright © 2016年 颜建文. All rights reserved. 7 | // 8 | 9 | #import "MainViewController.h" 10 | #import "PayViewController.h" 11 | #import 12 | 13 | @implementation MainViewController 14 | 15 | @synthesize itemTitles = _itemTitles; 16 | @synthesize childViewControllers = _childViewControllers; 17 | 18 | #pragma mark - life cycle 19 | 20 | - (void)viewDidLoad { 21 | [super viewDidLoad]; 22 | self.topBarView.isUseLeftExpandItem = NO; 23 | self.topBarView.isUseRightExpandItem = NO; 24 | self.topBarView.backgroundColor = [UIColor flatBlackColor]; 25 | self.topBarView.itemNormalColor = [UIColor flatGrayColorDark]; 26 | self.topBarView.itemSelectedColor = [UIColor flatWhiteColor]; 27 | self.isShowIndicatorView = NO; 28 | self.view.backgroundColor = [UIColor flatBlackColor]; 29 | self.pageLeftRightMargin = 10; 30 | self.pageTopMargin = 4; 31 | self.isUsePageConner = YES; 32 | 33 | } 34 | 35 | 36 | #pragma mark - Override 37 | 38 | - (UIStatusBarStyle)preferredStatusBarStyle{ 39 | 40 | return UIStatusBarStyleLightContent; 41 | 42 | } 43 | 44 | #pragma mark - getters 45 | 46 | - (NSArray *) itemTitles { 47 | if (!_itemTitles) { 48 | _itemTitles = @[@"PAY", @"STORES", @"GIFT"]; 49 | } 50 | return _itemTitles; 51 | } 52 | 53 | - (NSArray *) childViewControllers { 54 | if (!_childViewControllers) { 55 | 56 | UIStoryboard *payStoryboard = [UIStoryboard storyboardWithName:@"Pay" bundle:nil]; 57 | 58 | UINavigationController *vc1 = [payStoryboard instantiateViewControllerWithIdentifier:@"PayNavigationController"]; 59 | UIViewController *vc2 = [UIViewController new]; 60 | UIViewController *vc3 = [UIViewController new]; 61 | 62 | vc1.view.backgroundColor = [UIColor whiteColor]; 63 | vc2.view.backgroundColor = [UIColor whiteColor]; 64 | vc3.view.backgroundColor = [UIColor whiteColor]; 65 | 66 | _childViewControllers = @[vc1, vc2, vc3]; 67 | 68 | } 69 | 70 | return _childViewControllers; 71 | } 72 | 73 | 74 | @end 75 | -------------------------------------------------------------------------------- /1.StarbucksCreditCardInteractionDemo/StarbucksCreditCardInteractionDemo/PayCardInfoViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // PayCardInfoViewController.h 3 | // StarbucksCreditCardInteractionDemo 4 | // 5 | // Created by 颜建文 on 16/5/30. 6 | // Copyright © 2016年 颜建文. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface PayCardInfoViewController : UIViewController 12 | 13 | @property (nonatomic, assign) NSUInteger startPage; 14 | 15 | @end 16 | -------------------------------------------------------------------------------- /1.StarbucksCreditCardInteractionDemo/StarbucksCreditCardInteractionDemo/PayCardInfoViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // PayCardInfoViewController.m 3 | // StarbucksCreditCardInteractionDemo 4 | // 5 | // Created by 颜建文 on 16/5/30. 6 | // Copyright © 2016年 颜建文. All rights reserved. 7 | // 8 | 9 | #import "PayCardInfoViewController.h" 10 | #import "YanBannerView.h" 11 | #import 12 | #import "UIView+PopAnimation.h" 13 | #import 14 | 15 | @interface PayCardInfoViewController () 16 | 17 | @property (weak, nonatomic) IBOutlet YanBannerView *cardBannerView; 18 | @property (nonatomic, strong) NSArray *payCardList; 19 | @property (weak, nonatomic) IBOutlet UIButton *doneButton; 20 | @property (weak, nonatomic) IBOutlet UIView *cardInfoView; 21 | 22 | @end 23 | 24 | @implementation PayCardInfoViewController 25 | 26 | - (void)viewDidLoad { 27 | [super viewDidLoad]; 28 | // Do any additional setup after loading the view. 29 | 30 | self.cardBannerView.pageControl.pageIndicatorTintColor = [UIColor flatWhiteColor]; 31 | self.cardBannerView.pageControl.currentPageIndicatorTintColor = [UIColor flatGrayColor]; 32 | self.doneButton.alpha = 0; 33 | self.cardInfoView.alpha = 0; 34 | [self.doneButton setBackgroundColor:[UIColor flatCoffeeColor]]; 35 | } 36 | 37 | - (void)viewDidAppear:(BOOL)animated { 38 | [super viewDidAppear:animated]; 39 | self.cardBannerView.delegate = self; 40 | self.cardBannerView.startPage = self.startPage; 41 | 42 | [self.doneButton addCardFlyAppearAnimationFromPositionY: CGRectGetHeight([UIScreen mainScreen].bounds)]; 43 | [self.cardInfoView addAppearAnimationWithVelocity:4.0]; 44 | 45 | } 46 | 47 | 48 | #pragma mark - YanBannerView datasource 49 | 50 | - (NSUInteger)numberOfBannerCellInYanBannerView:(YanBannerView *)yanBannerView { 51 | return self.payCardList.count; 52 | } 53 | 54 | - (CGFloat)widthOfBannerCellInYanBannerView:(YanBannerView *)yanBannerView { 55 | return CGRectGetWidth(self.cardBannerView.frame); 56 | } 57 | 58 | - (CGFloat)offsetOfPageControl:(YanBannerView *)yanBannerView { 59 | return 8.0; 60 | } 61 | 62 | 63 | - (YanBannerViewCell *)yanBannerView:(YanBannerView *)yanBannerView cellForIndex:(NSInteger)index { 64 | YanBannerViewCell *cell = [YanBannerViewCell new]; 65 | cell.titleLabel.hidden = YES; 66 | cell.image = [UIImage imageNamed:self.payCardList[index]]; 67 | cell.bannerImageView.contentMode = UIViewContentModeRedraw; 68 | return cell; 69 | } 70 | 71 | #pragma mark - events response 72 | 73 | - (IBAction)back:(id)sender { 74 | 75 | [self.navigationController popViewControllerAnimated:YES]; 76 | } 77 | 78 | - (IBAction)success:(UIButton *)sender { 79 | 80 | UIView *maskView = [[UIView alloc]initWithFrame: CGRectMake(self.view.frame.origin.x, CGRectGetMaxY(self.view.frame), CGRectGetWidth(self.view.frame), CGRectGetHeight(self.view.frame)) 81 | ]; 82 | maskView.backgroundColor = [UIColor flatCoffeeColor]; 83 | [self.view addSubview:maskView]; 84 | 85 | 86 | POPSpringAnimation *colorAnimation = [POPSpringAnimation animationWithPropertyNamed:kPOPLayerBackgroundColor]; 87 | colorAnimation.toValue = [UIColor whiteColor]; 88 | [colorAnimation setCompletionBlock:^(POPAnimation *a, BOOL s) { 89 | [self performSegueWithIdentifier:@"PaySuccessSegueIdentifier" sender:self]; 90 | [maskView removeFromSuperview]; 91 | }]; 92 | 93 | [[maskView addFlyAnimationToCenter:self.view.center springSpeed:0] setCompletionBlock:^(POPAnimation *animation, BOOL isFinish) { 94 | if (isFinish) { 95 | [maskView.layer pop_addAnimation:colorAnimation forKey:@"kColorAnimation"]; 96 | } 97 | }]; 98 | 99 | } 100 | 101 | #pragma mark - getters 102 | 103 | - (NSArray *)payCardList { 104 | if (!_payCardList) { 105 | _payCardList = @[ 106 | @"apple_pay_large", 107 | @"visa_large", 108 | @"master_large", 109 | ]; 110 | } 111 | return _payCardList; 112 | } 113 | 114 | @end 115 | -------------------------------------------------------------------------------- /1.StarbucksCreditCardInteractionDemo/StarbucksCreditCardInteractionDemo/PaySuccessViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // PaySuccessViewController.h 3 | // StarbucksCreditCardInteractionDemo 4 | // 5 | // Created by 颜建文 on 16/6/6. 6 | // Copyright © 2016年 颜建文. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface PaySuccessViewController : UIViewController 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /1.StarbucksCreditCardInteractionDemo/StarbucksCreditCardInteractionDemo/PaySuccessViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // PaySuccessViewController.m 3 | // StarbucksCreditCardInteractionDemo 4 | // 5 | // Created by 颜建文 on 16/6/6. 6 | // Copyright © 2016年 颜建文. All rights reserved. 7 | // 8 | 9 | #import "PaySuccessViewController.h" 10 | #import 11 | #import "UIView+PopAnimation.h" 12 | #import 13 | 14 | @interface PaySuccessViewController () 15 | @property (weak, nonatomic) IBOutlet UIImageView *backImageView; 16 | @property (weak, nonatomic) IBOutlet UIImageView *cupImageView; 17 | @property (weak, nonatomic) IBOutlet UILabel *hurryLabel; 18 | 19 | @end 20 | 21 | @implementation PaySuccessViewController 22 | 23 | - (void)viewDidLoad { 24 | [super viewDidLoad]; 25 | // Do any additional setup after loading the view. 26 | self.backImageView.alpha = 0; 27 | self.cupImageView.alpha = 0; 28 | self.hurryLabel.alpha = 0; 29 | } 30 | 31 | - (void)viewDidAppear:(BOOL)animated { 32 | 33 | [super viewDidAppear: animated]; 34 | [self scaleAnimation]; 35 | 36 | } 37 | 38 | - (void)didReceiveMemoryWarning { 39 | [super didReceiveMemoryWarning]; 40 | // Dispose of any resources that can be recreated. 41 | } 42 | 43 | - (void)scaleAnimation { 44 | POPBasicAnimation *anim = [POPBasicAnimation animationWithPropertyNamed:kPOPLayerScaleXY]; 45 | 46 | anim.fromValue = [NSValue valueWithCGPoint:CGPointMake(3.0, 3.0)]; 47 | anim.toValue = [NSValue valueWithCGPoint:CGPointMake(1.0, 1.0)]; 48 | 49 | anim.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]; 50 | [anim setCompletionBlock:^(POPAnimation *animation, BOOL isFinish) { 51 | if (isFinish) { 52 | [self.cupImageView addCardFlyAppearAnimationFromPositionY:CGRectGetMaxY(self.backImageView.frame)]; 53 | [self.hurryLabel addAppearAnimationWithVelocity:4.0]; 54 | } 55 | }]; 56 | [self.backImageView.layer pop_addAnimation:anim forKey:@"scaleAnimation"]; 57 | [self.backImageView addAppearAnimationWithVelocity:4.0]; 58 | } 59 | 60 | 61 | - (IBAction)restart:(UIButton *)sender { 62 | [self.navigationController popToRootViewControllerAnimated:YES]; 63 | } 64 | 65 | @end 66 | -------------------------------------------------------------------------------- /1.StarbucksCreditCardInteractionDemo/StarbucksCreditCardInteractionDemo/PayViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // PayViewController.h 3 | // StarbucksCreditCardInteractionDemo 4 | // 5 | // Created by 颜建文 on 16/5/28. 6 | // Copyright © 2016年 颜建文. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "iCarousel.h" 11 | 12 | @interface PayViewController : UIViewController 13 | 14 | @property (weak, nonatomic) IBOutlet UILabel *orLabel; 15 | @property (weak, nonatomic) IBOutlet UILabel *agreementLabel; 16 | @property (weak, nonatomic) IBOutlet UIImageView *starbucksCardImageView; 17 | @property (weak, nonatomic) IBOutlet iCarousel *payCardCarousel; 18 | 19 | @end 20 | -------------------------------------------------------------------------------- /1.StarbucksCreditCardInteractionDemo/StarbucksCreditCardInteractionDemo/PayViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // PayViewController.m 3 | // StarbucksCreditCardInteractionDemo 4 | // 5 | // Created by 颜建文 on 16/5/28. 6 | // Copyright © 2016年 颜建文. All rights reserved. 7 | // 8 | 9 | #import "PayViewController.h" 10 | #import 11 | #import "UIView+PopAnimation.h" 12 | #import "PayCardInfoViewController.h" 13 | 14 | 15 | @interface PayViewController () 16 | 17 | @property (nonatomic, assign) CGFloat payCardWidth; 18 | @property (nonatomic, assign) BOOL isUserCardScaleAnimation; 19 | @property (nonatomic, strong) NSArray *payCardList; 20 | 21 | @end 22 | 23 | @implementation PayViewController 24 | 25 | #pragma mark - life cycle 26 | 27 | - (void)viewDidLoad { 28 | [super viewDidLoad]; 29 | // Do any additional setup after loading the view. 30 | self.payCardCarousel.type = iCarouselTypeRotary; 31 | self.payCardCarousel.pagingEnabled =YES; 32 | self.orLabel.text = @"OR"; 33 | self.agreementLabel.text = @"I agree to Starbucks Card Terms and \r\n Condtions"; 34 | } 35 | 36 | - (void)viewWillAppear:(BOOL)animated { 37 | [super viewWillAppear: animated]; 38 | self.starbucksCardImageView.alpha = 0; 39 | self.payCardCarousel.alpha = 0; 40 | self.orLabel.alpha = 0; 41 | self.agreementLabel.alpha = 0; 42 | } 43 | 44 | - (void)viewDidAppear:(BOOL)animated { 45 | [super viewDidAppear:animated]; 46 | [self enterViewControlelr]; 47 | /* [self.payCardCarousel.currentItemView addFlyAnimationToPositionY:(self.starbucksCardImageView.frame.origin.y - self.payCardCarousel.frame.origin.y + 50) springSpeed:0]; 48 | POPBaseAnimation *animation =*/ 49 | } 50 | 51 | #pragma maek - iCarousel Delegate 52 | 53 | - (void)carouselDidEndScrollingAnimation:(iCarousel *)carousel { 54 | if (carousel == self.payCardCarousel) { 55 | if (self.isUserCardScaleAnimation) { 56 | [self.payCardCarousel.currentItemView addJellyAnimation]; 57 | } else { 58 | self.isUserCardScaleAnimation = YES; 59 | } 60 | } 61 | } 62 | 63 | - (CGFloat)carousel:(__unused iCarousel *)carousel valueForOption:(iCarouselOption)option withDefault:(CGFloat)value { 64 | //customize carousel display 65 | switch (option) 66 | { 67 | case iCarouselOptionWrap: 68 | { 69 | //normally you would hard-code this to YES or NO 70 | return YES; 71 | } 72 | case iCarouselOptionSpacing: 73 | { 74 | //add a bit of spacing between the item views 75 | return value * 1.15f; 76 | } 77 | case iCarouselOptionArc: 78 | { 79 | return M_PI /2; 80 | } 81 | case iCarouselOptionFadeMax: 82 | case iCarouselOptionShowBackfaces: 83 | case iCarouselOptionRadius: 84 | case iCarouselOptionAngle: 85 | case iCarouselOptionTilt: 86 | case iCarouselOptionCount: 87 | case iCarouselOptionFadeMin: 88 | case iCarouselOptionFadeMinAlpha: 89 | case iCarouselOptionFadeRange: 90 | case iCarouselOptionOffsetMultiplier: 91 | case iCarouselOptionVisibleItems: 92 | { 93 | return value; 94 | } 95 | } 96 | } 97 | 98 | - (void)carousel:(iCarousel *)carousel didSelectItemAtIndex:(NSInteger)index { 99 | 100 | if (carousel.currentItemIndex == index) { 101 | [carousel.currentItemView pop_removeAllAnimations]; 102 | 103 | //add left and right cards remove animation 104 | NSInteger rightIndex = carousel.currentItemIndex >= carousel.numberOfItems - 1 ? 0 : carousel.currentItemIndex + 1; 105 | NSInteger leftIndex = carousel.currentItemIndex == 0 ? carousel.numberOfItems - 1 : carousel.currentItemIndex - 1; 106 | [carousel.visibleItemViews[leftIndex] addCardFlyDisappearAnimationToPositionX:-100]; 107 | [carousel.visibleItemViews[rightIndex] addCardFlyDisappearAnimationToPositionX:CGRectGetWidth([UIScreen mainScreen].bounds) + 100]; 108 | 109 | //add starbucks image remove animation 110 | [self.starbucksCardImageView addFlyAnimationToPositionY:-CGRectGetHeight(self.starbucksCardImageView.bounds) springSpeed:0]; 111 | 112 | //add label dispaear animation 113 | [self.orLabel addDisappearAnimationWithVelocity:4.0]; 114 | [self.agreementLabel addDisappearAnimationWithVelocity:4.0]; 115 | 116 | //add card move to top animation 117 | POPPropertyAnimation *cardAnimation = [carousel.currentItemView addCardFlyLargeAnimationToPositionY:(self.starbucksCardImageView.center.y - self.payCardCarousel.frame.origin.y) - 28]; 118 | 119 | [cardAnimation setCompletionBlock:^(POPAnimation *a, BOOL b) { 120 | [self leaveViewController]; 121 | }]; 122 | } 123 | 124 | } 125 | 126 | #pragma mark - iCarousel Data Source 127 | 128 | - (NSInteger)numberOfItemsInCarousel:(iCarousel *)carousel { 129 | if (carousel == self.payCardCarousel) { 130 | return self.payCardList.count; 131 | } 132 | return 0; 133 | } 134 | 135 | - (UIView *)carousel:(iCarousel *)carousel viewForItemAtIndex:(NSInteger)index reusingView:(nullable UIView *)view { 136 | //create new view if no view is available for recycling 137 | if (view == nil) 138 | { 139 | view = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, self.payCardWidth, self.payCardWidth * 356 / 571)]; 140 | ((UIImageView *)view).image = [UIImage imageNamed:self.payCardList[index]]; 141 | ((UIImageView *)view).contentMode = UIViewContentModeRedraw; 142 | ((UIImageView *)view).layer.masksToBounds = YES; 143 | 144 | } 145 | return view; 146 | }; 147 | 148 | #pragma mark - Navigation 149 | 150 | - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { 151 | if ([segue.identifier isEqualToString:NSStringFromClass([PayCardInfoViewController class])]) { 152 | if ([segue.destinationViewController isKindOfClass:[PayCardInfoViewController class]]) { 153 | PayCardInfoViewController *pcivc = (PayCardInfoViewController *)segue.destinationViewController; 154 | pcivc.startPage = self.payCardCarousel.currentItemIndex; 155 | } 156 | } 157 | } 158 | 159 | #pragma mark - private instance method 160 | 161 | - (void)enterViewControlelr { 162 | self.isUserCardScaleAnimation = NO; 163 | self.payCardWidth = CGRectGetWidth(self.view.bounds) - 40; 164 | self.payCardCarousel.delegate = self; 165 | self.payCardCarousel.dataSource = self; 166 | 167 | //first time run animation delay 0.5s for lanuch 168 | static CGFloat startAnimationDelayTime = 0.5; 169 | 170 | dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(startAnimationDelayTime 171 | * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ 172 | startAnimationDelayTime = 0; 173 | self.payCardCarousel.hidden = NO; 174 | [self.starbucksCardImageView addCardFlyRoateAnimationFromPositionY:CGRectGetMaxY(self.orLabel.frame) angel:M_PI_4/2]; 175 | [self.orLabel addAppearAnimationWithVelocity:4.0]; 176 | [self.agreementLabel addAppearAnimationWithVelocity:4.0]; 177 | [self.payCardCarousel addCardFlyAppearAnimationFromPositionY:CGRectGetMaxY(self.payCardCarousel.frame)]; 178 | 179 | }); 180 | 181 | } 182 | 183 | - (void)leaveViewController { 184 | dispatch_async(dispatch_get_main_queue(), ^{ 185 | self.payCardCarousel.hidden = YES; 186 | self.payCardCarousel.delegate = nil; 187 | self.payCardCarousel.dataSource = nil; 188 | [self performSegueWithIdentifier:NSStringFromClass([PayCardInfoViewController class]) sender:self]; 189 | }); 190 | } 191 | 192 | #pragma mark - getters 193 | 194 | - (NSArray *)payCardList { 195 | if (!_payCardList) { 196 | _payCardList = @[@"apple_pay", @"visa_card", @"master_card"]; 197 | } 198 | return _payCardList; 199 | } 200 | 201 | 202 | @end 203 | -------------------------------------------------------------------------------- /1.StarbucksCreditCardInteractionDemo/StarbucksCreditCardInteractionDemo/UIView+PopAnimation.h: -------------------------------------------------------------------------------- 1 | // 2 | // UIView+PopAnimation.h 3 | // StarbucksCreditCardInteractionDemo 4 | // 5 | // Created by 颜建文 on 16/6/1. 6 | // Copyright © 2016年 颜建文. All rights reserved. 7 | // 8 | 9 | #import 10 | #import 11 | 12 | @interface UIView(PopAnimation) 13 | 14 | #pragma mark - Basic Animation 15 | - (POPPropertyAnimation *)addAppearAnimationWithVelocity:(CGFloat)velocity; 16 | - (void)removeAppearAnimation; 17 | 18 | - (POPPropertyAnimation *)addDisappearAnimationWithVelocity:(CGFloat)velocity; 19 | - (void)removeDisappearAnimation; 20 | 21 | - (POPPropertyAnimation *)addFlyAnimationFromPositionY:(CGFloat)positionY springSpeed:(CGFloat)springSpeed; 22 | - (void)removeFlyAnimationFromPostionY; 23 | 24 | - (POPPropertyAnimation *)addFlyAnimationToPositionY:(CGFloat)positionY springSpeed:(CGFloat)springSpeed; 25 | - (void)removeFlyAnimationToPostionY; 26 | 27 | - (POPPropertyAnimation *)addFlyAnimationFromPositionX:(CGFloat)positionX springSpeed:(CGFloat)springSpeed; 28 | - (void)removeFlyAnimationFromPostionX ; 29 | 30 | - (POPPropertyAnimation *)addFlyAnimationToPositionX:(CGFloat)positionX springSpeed:(CGFloat)springSpeed; 31 | - (void)removeFlyAnimationToPostionX; 32 | 33 | 34 | #pragma mark - Group Animation 35 | 36 | - (POPPropertyAnimation *)addJellyAnimation; 37 | - (void)removeJellyAnimation; 38 | 39 | - (POPPropertyAnimation *)addCardFlyAppearAnimationFromPositionY:(CGFloat)positionY; 40 | - (void)removeCardFlyAppearAnimationFromPositionY; 41 | 42 | - (POPPropertyAnimation *)addCardFlyDisappearAnimationFromPositionY:(CGFloat)positionY; 43 | - (void)removeCardFlyDisappearAnimationFromPositionY; 44 | 45 | - (POPPropertyAnimation *)addCardFlyDisappearAnimationToPositionY:(CGFloat)positionY; 46 | - (void)removeCardFlyDisappearAnimationToPositionY; 47 | 48 | - (POPPropertyAnimation *)addCardFlyDisappearAnimationToPositionX:(CGFloat)positionX; 49 | - (void)removeCardFlyDisappearAnimationToPositionX; 50 | 51 | - (POPPropertyAnimation *)addCardFlyRoateAnimationFromPositionY:(CGFloat)positionY angel:(CGFloat)angel; 52 | - (void)removeCardFlyRoateAnimationFromPositionY; 53 | 54 | - (POPPropertyAnimation *)addCardFlyLargeAnimationToPositionY:(CGFloat)positionY; 55 | - (void)removeCardFlyLargeAnimationToPositionY; 56 | 57 | - (POPPropertyAnimation *)addFlyAnimationToCenter:(CGPoint)center springSpeed:(CGFloat)springSpeed; 58 | - (void)removeFlyAnimationToCenter; 59 | 60 | 61 | @end 62 | -------------------------------------------------------------------------------- /1.StarbucksCreditCardInteractionDemo/StarbucksCreditCardInteractionDemo/UIView+PopAnimation.m: -------------------------------------------------------------------------------- 1 | // 2 | // UIView+PopAnimation.m 3 | // StarbucksCreditCardInteractionDemo 4 | // 5 | // Created by 颜建文 on 16/6/1. 6 | // Copyright © 2016年 颜建文. All rights reserved. 7 | // 8 | 9 | #import "UIView+PopAnimation.h" 10 | 11 | 12 | NSString *const kAppearAnimation = @"kAppearAnimation"; 13 | NSString *const kDisappearAnimation = @"kDisappearAnimation"; 14 | 15 | NSString *const kJellyAnimationSmall = @"kJellyAnimationSmall"; 16 | NSString *const kJellyAnimationNormal = @"kJellyAnimationNormal"; 17 | NSString *const kJellyAnimationLarge = @"kJellyAnimationLarge"; 18 | 19 | NSString *const kRoateAnimation = @"kRoateAnimation"; 20 | NSString *const kFlyAnimationToPositionY = @"kFlyAnimationToPositionY"; 21 | NSString *const kFlyAnimationFromPositionY = @"kFlyAnimationFromPositionY"; 22 | NSString *const kFlyAnimationToPositionX = @"kFlyAnimationToPositionX"; 23 | NSString *const kFlyAnimationFromPositionX = @"kFlyAnimationFromPositionX"; 24 | NSString *const kFlyAnimationFromCenter = @"kFlyAnimationFromCenter"; 25 | 26 | NSString *const kCardLargeAnimation = @"kCardLargeAnimation"; 27 | 28 | NSString *const kCardFlyAnimationAppear = @"kCardFlyAnimationAppear"; 29 | NSString *const kCardFlyAnimationRoate = @"kCardFlyAnimationRoate"; 30 | NSString *const kCardFlyAnimationFly = @"kCardFlyAnimationFly"; 31 | NSString *const kCardAnimationRemove = @"kCardAnimationRemove"; 32 | 33 | 34 | @implementation UIView(PopAnimation) 35 | 36 | #pragma mark - Basic Animation 37 | 38 | - (POPPropertyAnimation *)addAppearAnimationWithVelocity:(CGFloat)velocity { 39 | POPDecayAnimation *appearAnimation = [POPDecayAnimation animationWithPropertyNamed:kPOPLayerOpacity]; 40 | appearAnimation.fromValue = @0.0; 41 | appearAnimation.velocity = @(fabs(velocity)); 42 | appearAnimation.deceleration = 0.998; 43 | [self.layer pop_addAnimation:appearAnimation forKey:kAppearAnimation]; 44 | return appearAnimation; 45 | } 46 | 47 | - (void)removeAppearAnimation { 48 | [self.layer pop_removeAnimationForKey:kAppearAnimation]; 49 | } 50 | 51 | - (POPPropertyAnimation *)addDisappearAnimationWithVelocity:(CGFloat)velocity { 52 | POPDecayAnimation *appearAnimation = [POPDecayAnimation animationWithPropertyNamed:kPOPLayerOpacity]; 53 | appearAnimation.fromValue = @1.0; 54 | appearAnimation.velocity = @(-fabs(velocity)); 55 | appearAnimation.deceleration = 0.998; 56 | [self.layer pop_addAnimation:appearAnimation forKey:kDisappearAnimation]; 57 | return appearAnimation; 58 | } 59 | 60 | - (void)removeDisappearAnimation { 61 | [self.layer pop_removeAnimationForKey:kDisappearAnimation]; 62 | } 63 | 64 | - (POPPropertyAnimation *)addRoateAniamationFromAngel:(CGFloat)fromAngel toAngel:(CGFloat)toAngel { 65 | POPSpringAnimation *roateAnimation = [POPSpringAnimation animationWithPropertyNamed:kPOPLayerRotation]; 66 | 67 | roateAnimation.fromValue = @(fromAngel); 68 | roateAnimation.toValue = @(toAngel); 69 | roateAnimation.dynamicsTension = 100; 70 | 71 | [self.layer pop_addAnimation:roateAnimation forKey:kRoateAnimation]; 72 | 73 | return roateAnimation; 74 | } 75 | 76 | - (void)removeRoateAnimation { 77 | [self.layer pop_animationForKey:kRoateAnimation]; 78 | } 79 | 80 | 81 | - (POPPropertyAnimation *)addFlyAnimationFromPositionY:(CGFloat)positionY springSpeed:(CGFloat)springSpeed { 82 | 83 | POPSpringAnimation *flyAnimation = [POPSpringAnimation animationWithPropertyNamed:kPOPLayerPositionY]; 84 | flyAnimation.fromValue = @(positionY); 85 | if (springSpeed > 0) { 86 | flyAnimation.springSpeed = springSpeed; 87 | } 88 | flyAnimation.dynamicsTension = 100; 89 | [self.layer pop_addAnimation:flyAnimation forKey:kFlyAnimationFromPositionY]; 90 | 91 | return flyAnimation; 92 | } 93 | 94 | - (void)removeFlyAnimationFromPostionY { 95 | [self.layer pop_removeAnimationForKey:kFlyAnimationFromPositionY]; 96 | } 97 | 98 | - (POPPropertyAnimation *)addFlyAnimationToPositionY:(CGFloat)positionY springSpeed:(CGFloat)springSpeed { 99 | 100 | POPSpringAnimation *flyAnimation = [POPSpringAnimation animationWithPropertyNamed:kPOPLayerPositionY]; 101 | flyAnimation.toValue = @(positionY); 102 | if (springSpeed > 0) { 103 | flyAnimation.springSpeed = springSpeed; 104 | } 105 | flyAnimation.dynamicsTension = 100; 106 | [self.layer pop_addAnimation:flyAnimation forKey:kFlyAnimationToPositionY]; 107 | 108 | return flyAnimation; 109 | } 110 | 111 | - (void)removeFlyAnimationToPostionY { 112 | [self.layer pop_removeAnimationForKey:kFlyAnimationToPositionY]; 113 | } 114 | 115 | - (POPPropertyAnimation *)addFlyAnimationFromPositionX:(CGFloat)positionX springSpeed:(CGFloat)springSpeed { 116 | 117 | POPSpringAnimation *flyAnimation = [POPSpringAnimation animationWithPropertyNamed:kPOPLayerPositionX]; 118 | flyAnimation.fromValue = @(positionX); 119 | if (springSpeed > 0) { 120 | flyAnimation.springSpeed = springSpeed; 121 | } 122 | flyAnimation.dynamicsTension = 100; 123 | [self.layer pop_addAnimation:flyAnimation forKey:kFlyAnimationFromPositionX]; 124 | 125 | return flyAnimation; 126 | } 127 | 128 | - (void)removeFlyAnimationFromPostionX { 129 | [self.layer pop_removeAnimationForKey:kFlyAnimationFromPositionX]; 130 | } 131 | 132 | - (POPPropertyAnimation *)addFlyAnimationToPositionX:(CGFloat)positionX springSpeed:(CGFloat)springSpeed { 133 | 134 | POPSpringAnimation *flyAnimation = [POPSpringAnimation animationWithPropertyNamed:kPOPLayerPositionX]; 135 | flyAnimation.toValue = @(positionX); 136 | if (springSpeed > 0) { 137 | flyAnimation.springSpeed = springSpeed; 138 | } 139 | flyAnimation.dynamicsTension = 100; 140 | [self.layer pop_addAnimation:flyAnimation forKey:kFlyAnimationToPositionX]; 141 | 142 | return flyAnimation; 143 | } 144 | 145 | - (void)removeFlyAnimationToPostionX { 146 | [self.layer pop_removeAnimationForKey:kFlyAnimationToPositionX]; 147 | } 148 | 149 | - (POPPropertyAnimation *)addFlyAnimationToCenter:(CGPoint)center springSpeed:(CGFloat)springSpeed { 150 | POPSpringAnimation *flyAnimation = [POPSpringAnimation animationWithPropertyNamed:kPOPViewCenter]; 151 | flyAnimation.toValue = [NSValue valueWithCGPoint:center]; 152 | if (springSpeed > 0) { 153 | flyAnimation.springSpeed = springSpeed; 154 | } 155 | [self pop_addAnimation:flyAnimation forKey:kFlyAnimationFromCenter]; 156 | return flyAnimation; 157 | } 158 | 159 | - (void)removeFlyAnimationToCenter { 160 | [self.layer pop_removeAnimationForKey:kFlyAnimationFromCenter]; 161 | } 162 | 163 | 164 | #pragma mark - Group Animation 165 | 166 | - (POPPropertyAnimation *)addJellyAnimation { 167 | POPSpringAnimation *jellySmallAnimation = [POPSpringAnimation animationWithPropertyNamed:kPOPLayerScaleXY]; 168 | jellySmallAnimation.toValue = [NSValue valueWithCGPoint:CGPointMake(0.98, 0.98)]; 169 | jellySmallAnimation.springSpeed = 20; 170 | 171 | POPSpringAnimation *jellyNormalAnimation = [POPSpringAnimation animationWithPropertyNamed:kPOPLayerScaleXY]; 172 | jellyNormalAnimation.toValue = [NSValue valueWithCGPoint:CGPointMake(1.0, 1.0)]; 173 | jellyNormalAnimation.springSpeed = 20; 174 | 175 | POPSpringAnimation *cardLargeAnimation = [POPSpringAnimation animationWithPropertyNamed:kPOPLayerScaleXY]; 176 | cardLargeAnimation.toValue = [NSValue valueWithCGPoint:CGPointMake(1.02, 1.02)]; 177 | cardLargeAnimation.springSpeed = 20; 178 | 179 | [cardLargeAnimation setCompletionBlock:^(POPAnimation *anmation, BOOL isFinish) { 180 | if (isFinish) { 181 | [self.layer pop_addAnimation:jellySmallAnimation forKey:kJellyAnimationSmall]; 182 | } 183 | }]; 184 | 185 | [jellySmallAnimation setCompletionBlock:^(POPAnimation *anmation, BOOL isFinish) { 186 | if (isFinish) { 187 | [self.layer pop_addAnimation:jellyNormalAnimation forKey:kJellyAnimationNormal]; 188 | } 189 | }]; 190 | 191 | [self.layer pop_addAnimation:cardLargeAnimation forKey:kJellyAnimationLarge]; 192 | return jellyNormalAnimation; 193 | } 194 | 195 | - (void)removeJellyAnimation { 196 | [self.layer pop_removeAnimationForKey:kJellyAnimationSmall]; 197 | [self.layer pop_removeAnimationForKey:kJellyAnimationNormal]; 198 | [self.layer pop_removeAnimationForKey:kJellyAnimationLarge]; 199 | } 200 | 201 | - (POPPropertyAnimation *)addCardFlyAppearAnimationFromPositionY:(CGFloat)positionY { 202 | [self addAppearAnimationWithVelocity:4.0]; 203 | return [self addFlyAnimationFromPositionY:positionY springSpeed:0];; 204 | } 205 | 206 | - (void)removeCardFlyAppearAnimationFromPositionY { 207 | [self removeAppearAnimation]; 208 | [self removeFlyAnimationFromPostionY]; 209 | } 210 | 211 | - (POPPropertyAnimation *)addCardFlyDisappearAnimationFromPositionY:(CGFloat)positionY { 212 | [self addDisappearAnimationWithVelocity:4.0]; 213 | return [self addFlyAnimationFromPositionY:positionY springSpeed:0];; 214 | } 215 | 216 | - (void)removeCardFlyDisappearAnimationFromPositionY { 217 | [self removeDisappearAnimation]; 218 | [self removeFlyAnimationFromPostionY]; 219 | } 220 | 221 | - (POPPropertyAnimation *)addCardFlyAppearAnimationToPositionY:(CGFloat)positionY { 222 | [self addAppearAnimationWithVelocity:4.0]; 223 | return [self addFlyAnimationToPositionY:positionY springSpeed:0];; 224 | } 225 | 226 | - (void)removeCardFlyAppearAnimationToPositionY { 227 | [self removeAppearAnimation]; 228 | [self removeFlyAnimationToPostionY]; 229 | } 230 | 231 | - (POPPropertyAnimation *)addCardFlyDisappearAnimationToPositionY:(CGFloat)positionY { 232 | [self addDisappearAnimationWithVelocity:4.0]; 233 | return [self addFlyAnimationToPositionY:positionY springSpeed:0];; 234 | } 235 | 236 | - (void)removeCardFlyDisappearAnimationToPositionY { 237 | [self removeDisappearAnimation]; 238 | [self removeFlyAnimationToPostionY]; 239 | } 240 | 241 | - (POPPropertyAnimation *)addCardFlyDisappearAnimationToPositionX:(CGFloat)positionX { 242 | [self addDisappearAnimationWithVelocity:4.0]; 243 | return [self addFlyAnimationToPositionX:positionX springSpeed:0]; 244 | } 245 | 246 | - (void)removeCardFlyDisappearAnimationToPositionX { 247 | [self removeDisappearAnimation]; 248 | [self removeFlyAnimationToPostionX]; 249 | } 250 | 251 | - (POPPropertyAnimation *)addCardFlyRoateAnimationFromPositionY:(CGFloat)positionY angel:(CGFloat)angel { 252 | [self addRoateAniamationFromAngel:angel toAngel:0]; 253 | return [self addCardFlyAppearAnimationFromPositionY:positionY]; 254 | } 255 | 256 | - (void)removeCardFlyRoateAnimationFromPositionY { 257 | [self removeAppearAnimation]; 258 | [self removeCardFlyRoateAnimationFromPositionY]; 259 | } 260 | 261 | - (POPPropertyAnimation *)addCardFlyLargeAnimationToPositionY:(CGFloat)positionY { 262 | /* 263 | self.layer.masksToBounds = YES; 264 | 265 | [self addFlyAnimationToPositionY:positionY springSpeed:10]; 266 | 267 | POPSpringAnimation *connerSmallAnimation = [POPSpringAnimation animationWithPropertyNamed:kPOPLayerCornerRadius]; 268 | connerSmallAnimation.fromValue = @(0); 269 | connerSmallAnimation.toValue = @(self.frame.size.width/2); 270 | 271 | 272 | POPSpringAnimation *connerNormalAnimation = [POPSpringAnimation animationWithPropertyNamed:kPOPLayerCornerRadius]; 273 | connerNormalAnimation.toValue = @(0); 274 | 275 | 276 | POPSpringAnimation *cardLargeAnimation = [POPSpringAnimation animationWithPropertyNamed:kPOPLayerScaleXY]; 277 | cardLargeAnimation.toValue = [NSValue valueWithCGPoint:CGPointMake(1.24, 1.24)]; 278 | [self.layer pop_addAnimation:cardLargeAnimation forKey:kCardLargeAnimation]; 279 | 280 | [self.layer pop_addAnimation:connerSmallAnimation forKey:@"kConnerSmallAnimation"]; 281 | [connerSmallAnimation setCompletionBlock:^(POPAnimation *animation, BOOL isFinish) { 282 | if (isFinish) { 283 | [self.layer pop_addAnimation:connerNormalAnimation forKey:@"kConnerNormalAnimation"]; 284 | [self.layer pop_addAnimation:cardLargeAnimation forKey:kCardLargeAnimation]; 285 | } 286 | }]; 287 | */ 288 | 289 | POPSpringAnimation *cardLargeAnimation = [POPSpringAnimation animationWithPropertyNamed:kPOPLayerScaleXY]; 290 | cardLargeAnimation.toValue = [NSValue valueWithCGPoint:CGPointMake(1.20, 1.20)]; 291 | [self.layer pop_addAnimation:cardLargeAnimation forKey:kCardLargeAnimation]; 292 | [self addFlyAnimationToPositionY:positionY springSpeed:2]; 293 | 294 | return cardLargeAnimation; 295 | } 296 | 297 | - (void)removeCardFlyLargeAnimationToPositionY { 298 | [self.layer pop_removeAnimationForKey:kCardLargeAnimation]; 299 | [self removeFlyAnimationFromPostionY]; 300 | } 301 | 302 | @end 303 | -------------------------------------------------------------------------------- /1.StarbucksCreditCardInteractionDemo/StarbucksCreditCardInteractionDemo/kit/SpecialKeyBoardView.h: -------------------------------------------------------------------------------- 1 | // 2 | // SpecialKeyBoardView.h 3 | // StarbucksCreditCardInteractionDemo 4 | // 5 | // Created by 颜建文 on 16/6/3. 6 | // Copyright © 2016年 颜建文. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface SpecialKeyBoardView : UIView 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /1.StarbucksCreditCardInteractionDemo/StarbucksCreditCardInteractionDemo/kit/SpecialKeyBoardView.m: -------------------------------------------------------------------------------- 1 | // 2 | // SpecialKeyBoardView.m 3 | // StarbucksCreditCardInteractionDemo 4 | // 5 | // Created by 颜建文 on 16/6/3. 6 | // Copyright © 2016年 颜建文. All rights reserved. 7 | // 8 | 9 | #import "SpecialKeyBoardView.h" 10 | 11 | @implementation SpecialKeyBoardView 12 | 13 | /* 14 | // Only override drawRect: if you perform custom drawing. 15 | // An empty implementation adversely affects performance during animation. 16 | - (void)drawRect:(CGRect)rect { 17 | // Drawing code 18 | } 19 | */ 20 | 21 | @end 22 | -------------------------------------------------------------------------------- /1.StarbucksCreditCardInteractionDemo/StarbucksCreditCardInteractionDemo/kit/TopBarPageVController/TopBarIndicatorView.h: -------------------------------------------------------------------------------- 1 | // 2 | // TopBarIndicatorView.h 3 | // TopBarPageControllerDemo 4 | // 5 | // Created by 颜建文 on 15/11/16. 6 | // Copyright © 2015年 颜建文. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface TopBarIndicatorView : UIView 12 | 13 | typedef NS_ENUM(NSInteger, TopBarIndicatorType) { 14 | TopBarIndicatorTypeLine = 0, 15 | TopBarIndicatorTypeTriangle 16 | }; 17 | 18 | @property (strong, nonatomic) UIColor *color; 19 | @property (nonatomic, assign)TopBarIndicatorType indicatorType; 20 | 21 | - (id)initWithFrame:(CGRect)frame indicatorStyle:(TopBarIndicatorType)indicatorType indicatorColor:(UIColor *)color; 22 | @end 23 | -------------------------------------------------------------------------------- /1.StarbucksCreditCardInteractionDemo/StarbucksCreditCardInteractionDemo/kit/TopBarPageVController/TopBarIndicatorView.m: -------------------------------------------------------------------------------- 1 | // 2 | // TopBarIndicatorView.m 3 | // TopBarPageControllerDemo 4 | // 5 | // Created by 颜建文 on 15/11/16. 6 | // Copyright © 2015年 颜建文. All rights reserved. 7 | // 8 | 9 | #import "TopBarIndicatorView.h" 10 | 11 | @interface TopBarIndicatorView() 12 | 13 | @end 14 | 15 | @implementation TopBarIndicatorView 16 | 17 | - (id)initWithFrame:(CGRect)frame indicatorStyle:(TopBarIndicatorType)indicatorType indicatorColor:(UIColor *)color 18 | { 19 | self = [super initWithFrame:frame]; 20 | if (self) { 21 | self.opaque = NO; 22 | self.indicatorType = indicatorType; 23 | self.color = color; 24 | if (indicatorType == TopBarIndicatorTypeLine) { 25 | 26 | } 27 | } 28 | return self; 29 | } 30 | 31 | - (void)drawRect:(CGRect)rect { 32 | if (self.indicatorType == TopBarIndicatorTypeTriangle) { 33 | CGContextRef context = UIGraphicsGetCurrentContext(); 34 | 35 | CGContextClearRect(context, rect); 36 | 37 | CGContextBeginPath(context); 38 | CGContextMoveToPoint (context, CGRectGetMinX(rect), CGRectGetMinY(rect)); 39 | CGContextAddLineToPoint(context, CGRectGetMidX(rect), CGRectGetMaxY(rect)); 40 | CGContextAddLineToPoint(context, CGRectGetMaxX(rect), CGRectGetMinY(rect)); 41 | CGContextClosePath(context); 42 | 43 | CGContextSetFillColorWithColor(context, self.color.CGColor); 44 | CGContextFillPath(context); 45 | } else { 46 | [super drawRect:rect]; 47 | } 48 | } 49 | 50 | - (void)setColor:(UIColor *)color { 51 | [self setBackgroundColor:color]; 52 | } 53 | 54 | @end 55 | -------------------------------------------------------------------------------- /1.StarbucksCreditCardInteractionDemo/StarbucksCreditCardInteractionDemo/kit/TopBarPageVController/TopBarPageController.h: -------------------------------------------------------------------------------- 1 | // 2 | // TopBarPageController.h 3 | // Phobos 4 | // 5 | // Created by 颜建文 on 15/10/27. 6 | // Copyright © 2015年 颜建文. All rights reserved. 7 | // 8 | #import 9 | #import "TopBarView.h" 10 | 11 | @interface TopBarPageController : UIViewController 12 | 13 | @property (nonatomic, strong) NSArray *itemTitles; 14 | @property (nonatomic, strong) NSArray *childViewControllers; 15 | @property (nonatomic, strong, readonly)TopBarView *topBarView; 16 | 17 | @property (nonatomic, assign) BOOL isShowIndicatorView; 18 | @property (nonatomic, assign) BOOL isUsePageConner; 19 | @property (nonatomic, assign) CGFloat pageLeftRightMargin; 20 | @property (nonatomic, assign) CGFloat pageTopMargin; 21 | 22 | 23 | @end 24 | -------------------------------------------------------------------------------- /1.StarbucksCreditCardInteractionDemo/StarbucksCreditCardInteractionDemo/kit/TopBarPageVController/TopBarPageController.m: -------------------------------------------------------------------------------- 1 | // 2 | // TopBarPageController.m 3 | // Phobos 4 | // 5 | // Created by 颜建文 on 15/10/27. 6 | // Copyright © 2015年 颜建文. All rights reserved. 7 | // 8 | 9 | #import "TopBarPageController.h" 10 | #import "TopBarView.h" 11 | #import "UIColor+Fade.h" 12 | #import 13 | 14 | #define DEFAULT_TOP_BAR_HEIGHT (42.0) 15 | #define DEFAULT_INDICATOR_HEIGHT (2.0) 16 | #define DEFAULT_MAX_ITEMS_PER_SCREEN 4 17 | 18 | @interface TopBarPageController () 19 | 20 | @property (nonatomic, strong) TopBarView *topBarView; 21 | @property (nonatomic, strong) UIScrollView *pageScrollView; 22 | @property (nonatomic, strong) UIView *pageContainView; 23 | @property (nonatomic, assign, readonly) CGFloat pageWidth; 24 | @property (nonatomic, assign) NSInteger pageCount; 25 | @property (nonatomic, assign) NSInteger selectedIndex; 26 | @property (nonatomic, assign) NSInteger tapedItemIndex; 27 | 28 | @property (nonatomic, assign) CGFloat topBarHeight; 29 | @property (nonatomic, assign) NSInteger maxItemsPerPage; 30 | @property (nonatomic, strong) UIColor *topBarColor; 31 | @property (nonatomic, strong) UIFont *itemFont; 32 | 33 | //Configure expand item view 34 | @property (nonatomic, assign) BOOL isShowExpandItemView; 35 | @property (nonatomic, assign) BOOL isExpandViewWithMask; 36 | //Configure Page 37 | @property (nonatomic, assign) BOOL isAnimatedWhenTapItem; 38 | 39 | 40 | @end 41 | 42 | @implementation TopBarPageController 43 | 44 | #pragma mark - Default Configure 45 | 46 | /** 47 | * load default configure when view controller init 48 | */ 49 | - (void)loadDefaultConfigure { 50 | //Configure top bar 51 | self.topBarHeight = DEFAULT_TOP_BAR_HEIGHT; 52 | self.maxItemsPerPage = DEFAULT_MAX_ITEMS_PER_SCREEN; 53 | self.topBarColor = [UIColor whiteColor]; 54 | //grey 55 | self.topBarView.itemNormalColor = [[UIColor alloc] initWithHue:0.511 saturation:0.11 brightness:0.58 alpha:1.0]; 56 | //watermelon 57 | self.topBarView.itemSelectedColor = [[UIColor alloc] initWithHue:0.986 saturation:0.6 brightness:0.89 alpha:1.0]; 58 | self.itemFont = [UIFont systemFontOfSize:16.0]; 59 | 60 | //Configure page 61 | self.isAnimatedWhenTapItem = YES; 62 | 63 | //Configure expand View 64 | self.isShowExpandItemView = NO; 65 | self.isExpandViewWithMask = YES; 66 | self.selectedIndex = 0; 67 | self.tapedItemIndex = -1; 68 | self.isShowIndicatorView = YES; 69 | //self.pageLeftRightMargin = 0; 70 | } 71 | 72 | 73 | #pragma mark - View life cycle 74 | 75 | - (void)viewDidLoad { 76 | [super viewDidLoad]; 77 | 78 | // Do any additional setup after loading the view. 79 | 80 | // Check vaild 81 | if (self.itemTitles.count <= 0 || self.childViewControllers.count <=0 || 82 | self.itemTitles.count != self.childViewControllers.count ) { 83 | return; 84 | } 85 | //Load Default Configure 86 | [self loadDefaultConfigure]; 87 | 88 | // Add SubView 89 | [self.view addSubview:self.topBarView]; 90 | [self.view addSubview:self.pageScrollView]; 91 | 92 | [self.pageScrollView addSubview:self.pageContainView]; 93 | 94 | for (int index = 0; index < self.pageCount; index++) { 95 | UIViewController *childViewController = self.childViewControllers[index]; 96 | [self addChildViewController: childViewController]; 97 | [self.pageContainView addSubview:childViewController.view]; 98 | [self didMoveToParentViewController:self]; 99 | } 100 | 101 | // Auto Layout 102 | [self layoutSubview]; 103 | 104 | // KVO 105 | [self startObservingContentOffsetForPage]; 106 | 107 | // Move to seleted page 108 | CGPoint contentOffset = CGPointMake(self.selectedIndex * self.pageWidth, 0); 109 | [self.pageScrollView setContentOffset:contentOffset animated:YES]; 110 | } 111 | 112 | - (void)layoutSubview { 113 | 114 | [self.topBarView mas_makeConstraints:^(MASConstraintMaker *make) { 115 | make.top.equalTo(self.mas_topLayoutGuide); 116 | make.bottom.equalTo(self.mas_topLayoutGuide).with.offset(self.topBarHeight); 117 | make.trailing.equalTo(self.view.mas_trailing); 118 | make.leading.equalTo(self.view.mas_leading); 119 | }]; 120 | 121 | [self.pageScrollView mas_makeConstraints:^(MASConstraintMaker *make) { 122 | make.top.equalTo(self.topBarView.mas_bottom); 123 | make.left.right.and.bottom.equalTo(self.view); 124 | }]; 125 | 126 | [self.pageContainView mas_makeConstraints:^(MASConstraintMaker *make) { 127 | make.edges.equalTo(self.pageScrollView); 128 | make.bottom.equalTo(self.mas_bottomLayoutGuideBottom); 129 | }]; 130 | 131 | UIView *lastView = nil; 132 | 133 | for(UIViewController *vc in self.childViewControllers) { 134 | 135 | [vc.view mas_makeConstraints:^(MASConstraintMaker *make) { 136 | make.top.and.bottom.equalTo(self.pageContainView); 137 | make.width.mas_equalTo(@(self.pageWidth-self.pageLeftRightMargin*2)); 138 | if (lastView) { 139 | make.left.mas_equalTo(lastView.mas_right).offset(self.pageLeftRightMargin*2); 140 | } else { 141 | make.left.mas_equalTo(self.pageContainView.mas_left).offset(self.pageLeftRightMargin); 142 | } 143 | }]; 144 | 145 | lastView = vc.view; 146 | } 147 | 148 | [self.pageContainView mas_makeConstraints:^(MASConstraintMaker *make) { 149 | make.right.equalTo(lastView.mas_right).offset(self.pageLeftRightMargin); 150 | }]; 151 | } 152 | 153 | - (void)dealloc { 154 | [self stopObservingContentOffsetForPage]; 155 | } 156 | 157 | 158 | #pragma mark - ScrollView delegate 159 | 160 | - (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView { 161 | if (scrollView == self.pageScrollView) { 162 | CGFloat x = scrollView.contentOffset.x; 163 | self.selectedIndex = (x + self.pageWidth / 2) / self.pageWidth; 164 | scrollView.userInteractionEnabled = YES; 165 | } 166 | } 167 | 168 | - (void)scrollViewDidEndScrollingAnimation:(UIScrollView *)scrollView { 169 | if (scrollView == self.pageScrollView) { 170 | CGFloat x = scrollView.contentOffset.x; 171 | self.selectedIndex = (x + self.pageWidth / 2) / self.pageWidth; 172 | self.tapedItemIndex = -1; 173 | scrollView.userInteractionEnabled = YES; 174 | } 175 | } 176 | 177 | - (void)scrollViewDidEndDragging:(UIScrollView *)scrollView willDecelerate:(BOOL)decelerate 178 | { 179 | if (scrollView == self.pageScrollView && !decelerate) { 180 | scrollView.userInteractionEnabled = YES; 181 | } 182 | } 183 | 184 | - (void)scrollViewDidScroll:(UIScrollView *)scrollView 185 | { 186 | if (scrollView == self.pageScrollView) { 187 | scrollView.userInteractionEnabled = NO; 188 | 189 | } 190 | } 191 | 192 | #pragma mark - TopBarView delegate 193 | 194 | - (void)topBarView:(TopBarView *)topBarView didSelectItemAtIndex:(NSUInteger)index oldIndex:(NSUInteger)oldIndex { 195 | CGPoint contentOffset = CGPointMake(index * self.pageWidth, 0); 196 | self.tapedItemIndex = index; 197 | [self.pageScrollView setContentOffset:contentOffset animated:self.isAnimatedWhenTapItem]; 198 | if (!self.isAnimatedWhenTapItem) { 199 | [self.topBarView moveOldItem:oldIndex toSelectedItem:index]; 200 | } 201 | } 202 | 203 | #pragma mark - Event response 204 | 205 | #pragma mark -- Rotate orientation 206 | 207 | - (void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration 208 | { 209 | [self.topBarView updateLayout:self.selectedIndex]; 210 | 211 | //update layout 212 | for(UIViewController *vc in self.childViewControllers) { 213 | [vc.view mas_updateConstraints:^(MASConstraintMaker *make) { 214 | make.width.mas_equalTo(@(self.pageWidth)); 215 | }]; 216 | } 217 | 218 | //update offset 219 | CGPoint pageOffset = CGPointMake(self.selectedIndex * self.pageWidth, 0); 220 | [self.pageScrollView setContentOffset:pageOffset animated:NO]; 221 | [self.topBarView moveToSelectedItem:self.selectedIndex]; 222 | //for landspace -> portrait 223 | self.pageScrollView.userInteractionEnabled = YES; 224 | } 225 | 226 | #pragma mark -- KVO pageScrollView contentoffset 227 | 228 | - (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context { 229 | if ([keyPath isEqualToString:@"contentOffset"]) { 230 | [self updateTopbarView]; 231 | } 232 | } 233 | 234 | - (void)startObservingContentOffsetForPage { 235 | if (self.pageScrollView) [self.pageScrollView addObserver:self forKeyPath:@"contentOffset" options:0 context:nil]; 236 | } 237 | 238 | - (void)stopObservingContentOffsetForPage { 239 | if (self.pageScrollView) [self.pageScrollView removeObserver:self forKeyPath:@"contentOffset"]; 240 | } 241 | 242 | /** 243 | * update top bar scroll view offset, indicator offset and color fade 244 | */ 245 | - (void)updateTopbarView { 246 | //获取当前选中索引的oldOffset 247 | CGFloat oldOffsetX = self.selectedIndex * self.pageWidth; 248 | 249 | //oldOffset != contentOffset 且 需要检测实时偏移 250 | if (oldOffsetX != self.pageScrollView.contentOffset.x) { 251 | 252 | NSInteger targetIndex = (self.pageScrollView.contentOffset.x > oldOffsetX) ? self.selectedIndex + 1 : self.selectedIndex - 1; 253 | 254 | if (targetIndex >= 0 && targetIndex < self.pageCount) { 255 | //滑动比例 256 | CGFloat ratio = (self.pageScrollView.contentOffset.x - oldOffsetX) / self.pageWidth; 257 | ratio = fabs(ratio); 258 | //获取当前Item的Offset X 259 | CGFloat previousItemContentOffsetX = [self.topBarView contentOffsetForSelectedItemAtIndex:self.selectedIndex].x; 260 | //获取目标Item的Offset X 261 | CGFloat nextItemContentOffsetX = [self.topBarView contentOffsetForSelectedItemAtIndex:targetIndex].x 262 | ; 263 | //获取当前IndicatorX的位置 264 | CGFloat previousItemPageIndicatorX = self.topBarView.itemViewArray[self.selectedIndex].center.x; 265 | //获取目标IndicatorX的位置 266 | CGFloat nextItemPageIndicatorX = self.topBarView.itemViewArray[targetIndex].center.x; 267 | 268 | //配置button颜色 269 | UIButton *previosSelectedItem = self.topBarView.itemViewArray[self.selectedIndex]; 270 | UIButton *nextSelectedItem = self.topBarView.itemViewArray[(self.tapedItemIndex < 0) ? targetIndex : self.tapedItemIndex]; 271 | [previosSelectedItem setTitleColor:[UIColor moveColor:self.topBarView.itemSelectedColor toTargetColor:self.topBarView.itemNormalColor ratio:ratio] forState:UIControlStateNormal]; 272 | [nextSelectedItem setTitleColor:[UIColor moveColor:self.topBarView.itemNormalColor toTargetColor:self.topBarView.itemSelectedColor ratio:ratio] forState:UIControlStateNormal]; 273 | 274 | self.topBarView.scrollView.contentOffset = CGPointMake(previousItemContentOffsetX + 275 | (nextItemContentOffsetX - previousItemContentOffsetX) * ratio , 0.); 276 | self.topBarView.indicatorView.center = CGPointMake(previousItemPageIndicatorX + 277 | (nextItemPageIndicatorX - previousItemPageIndicatorX) * ratio, 278 | self.topBarView.indicatorView.center.y); 279 | } 280 | } 281 | } 282 | 283 | #pragma mark - getters and setters 284 | 285 | - (CGFloat)pageWidth { 286 | return CGRectGetWidth(self.view.frame); 287 | } 288 | 289 | - (NSInteger)pageCount { 290 | return self.childViewControllers ? self.childViewControllers.count : 0; 291 | } 292 | 293 | - (UIView *)pageContainView { 294 | if (!_pageContainView) { 295 | _pageContainView = [[UIView alloc]init]; 296 | } 297 | return _pageContainView; 298 | } 299 | 300 | - (UIScrollView *)pageScrollView { 301 | 302 | if (!_pageScrollView) { 303 | _pageScrollView = [[UIScrollView alloc] init]; 304 | _pageScrollView.pagingEnabled = YES; 305 | _pageScrollView.userInteractionEnabled = YES; 306 | _pageScrollView.showsVerticalScrollIndicator = NO; 307 | _pageScrollView.showsHorizontalScrollIndicator = NO; 308 | _pageScrollView.bounces = NO; 309 | _pageScrollView.delegate = self; 310 | } 311 | 312 | return _pageScrollView; 313 | } 314 | 315 | - (TopBarView *)topBarView { 316 | if (!_topBarView) { 317 | CGRect topBarViewFrame = CGRectMake(0, 0, CGRectGetWidth(self.view.bounds), self.topBarHeight); 318 | _topBarView = [[TopBarView alloc]initWithFrame:topBarViewFrame itemTitleArray:self.itemTitles maxItemCountOnShow:self.maxItemsPerPage]; 319 | _topBarView.itemFont = self.itemFont; 320 | _topBarView.delegate = self; 321 | _topBarView.isUseLeftExpandItem = YES; 322 | } 323 | return _topBarView; 324 | } 325 | 326 | - (void)setIsShowIndicatorView:(BOOL)isShowIndicatorView { 327 | if (_isShowIndicatorView != isShowIndicatorView) { 328 | _isShowIndicatorView = isShowIndicatorView; 329 | self.topBarView.indicatorView.hidden = !isShowIndicatorView; 330 | } 331 | } 332 | 333 | - (void)setPageLeftRightMargin:(CGFloat) margin { 334 | if (margin != _pageLeftRightMargin) { 335 | _pageLeftRightMargin = margin; 336 | [self updateTopbarViewLeftRightLayout:margin]; 337 | } 338 | } 339 | 340 | - (void)setPageTopMargin:(CGFloat)pageTopMargin { 341 | if (_pageTopMargin != pageTopMargin) { 342 | _pageTopMargin = pageTopMargin; 343 | [self updateTopbarViewTopLayout:pageTopMargin]; 344 | } 345 | } 346 | 347 | - (void)setIsUsePageConner:(BOOL)isUsePageConner { 348 | if (_isUsePageConner != isUsePageConner) { 349 | _isUsePageConner = isUsePageConner; 350 | } 351 | [self configPageConner:isUsePageConner]; 352 | } 353 | 354 | #pragma mark - private instance methods 355 | 356 | - (void)updateTopbarViewLeftRightLayout:(CGFloat)pageLeftRightMargin { 357 | UIView *lastView = nil; 358 | 359 | for(UIViewController *vc in self.childViewControllers) { 360 | 361 | [vc.view mas_updateConstraints:^(MASConstraintMaker *make) { 362 | make.width.mas_equalTo(@(self.pageWidth - pageLeftRightMargin*2)); 363 | if (lastView) { 364 | make.left.mas_equalTo(lastView.mas_right).offset(pageLeftRightMargin*2); 365 | } else { 366 | make.left.mas_equalTo(self.pageContainView.mas_left).offset(pageLeftRightMargin); 367 | } 368 | }]; 369 | 370 | lastView = vc.view; 371 | } 372 | 373 | [self.pageContainView mas_updateConstraints:^(MASConstraintMaker *make) { 374 | make.right.equalTo(lastView.mas_right).offset(self.pageLeftRightMargin); 375 | }]; 376 | 377 | if (self.isUsePageConner) { 378 | [self configPageConner: YES]; 379 | } 380 | } 381 | 382 | - (void)updateTopbarViewTopLayout:(CGFloat)pageTopMargin { 383 | for(UIViewController *vc in self.childViewControllers) { 384 | [vc.view mas_updateConstraints:^(MASConstraintMaker *make) { 385 | make.top.equalTo(self.pageContainView).offset(pageTopMargin); 386 | }]; 387 | } 388 | } 389 | 390 | - (void)configPageConner:(BOOL) isConner{ 391 | 392 | CGSize radii = isConner ? CGSizeMake(10, 10) : CGSizeMake(0, 0); 393 | 394 | for(UIViewController *vc in self.childViewControllers) { 395 | 396 | CGRect rect = CGRectMake(vc.view.bounds.origin.x, vc.view.bounds.origin.y, vc.view.bounds.size.width-self.pageLeftRightMargin*2, vc.view.bounds.size.height); 397 | 398 | UIBezierPath *maskPath = [UIBezierPath bezierPathWithRoundedRect:rect byRoundingCorners:UIRectCornerTopLeft|UIRectCornerTopRight cornerRadii:radii]; 399 | 400 | CAShapeLayer *maskLayer = [[CAShapeLayer alloc]init]; 401 | //设置大小 402 | maskLayer.frame = rect; 403 | //设置图形样子 404 | maskLayer.path = maskPath.CGPath; 405 | vc.view.layer.mask = maskLayer; 406 | } 407 | } 408 | 409 | 410 | @end 411 | -------------------------------------------------------------------------------- /1.StarbucksCreditCardInteractionDemo/StarbucksCreditCardInteractionDemo/kit/TopBarPageVController/TopBarView+ExpandItem.h: -------------------------------------------------------------------------------- 1 | // 2 | // TopBarView+ExpandItem.h 3 | // TopBarPageControllerDemo 4 | // 5 | // Created by 颜建文 on 15/11/28. 6 | // Copyright © 2015年 颜建文. All rights reserved. 7 | // 8 | 9 | #import "TopBarView.h" 10 | 11 | @interface TopBarView(ExpandItem) 12 | 13 | - (void)configureExpandItem; 14 | 15 | @end 16 | -------------------------------------------------------------------------------- /1.StarbucksCreditCardInteractionDemo/StarbucksCreditCardInteractionDemo/kit/TopBarPageVController/TopBarView+ExpandItem.m: -------------------------------------------------------------------------------- 1 | // 2 | // TopBarView+ExpandItem.m 3 | // TopBarPageControllerDemo 4 | // 5 | // Created by 颜建文 on 15/11/28. 6 | // Copyright © 2015年 颜建文. All rights reserved. 7 | // 8 | 9 | #import "TopBarView+ExpandItem.h" 10 | #import 11 | 12 | @implementation TopBarView(ExpandItem) 13 | 14 | /** 15 | * 配置ExpandItem 16 | */ 17 | - (void)configureExpandItem { 18 | 19 | 20 | 21 | if (self.isUseRightExpandItem) { 22 | [self configureRightExpanItem]; 23 | 24 | } 25 | 26 | if (self.isUseLeftExpandItem) { 27 | [self configureLeftExpandItem]; 28 | } 29 | 30 | [self autoLayoutItem]; 31 | 32 | } 33 | 34 | - (void)configureRightExpanItem { 35 | 36 | CGFloat itemWidth = CGRectGetHeight(self.frame) - CGRectGetHeight(self.indicatorView.frame); 37 | 38 | CGFloat rightItemX = CGRectGetWidth(self.frame)-CGRectGetHeight(self.frame); 39 | CGRect rightItemFrame = CGRectMake(rightItemX, 0, itemWidth, itemWidth); 40 | UIButton *rightItem = [UIButton buttonWithType:UIButtonTypeCustom]; 41 | rightItem.frame = rightItemFrame; 42 | [rightItem setTintColor:self.itemSelectedColor]; 43 | [rightItem setBackgroundColor:[UIColor colorWithWhite:1.0 alpha:0.8]]; 44 | UIImage *imageNormal = [[UIImage imageNamed:@"arrow-down" ] imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate]; 45 | UIImage *imageSelected = [[UIImage imageNamed:@"arrow-up" ] imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate]; 46 | [rightItem setImage:imageNormal forState:UIControlStateNormal]; 47 | [rightItem setImage:imageSelected forState:UIControlStateSelected]; 48 | [rightItem addTarget:self action:@selector(selectRightItem:) forControlEvents:UIControlEventTouchUpInside]; 49 | rightItem.selected = NO; 50 | [self addSubview:rightItem]; 51 | 52 | //AutoLayout 53 | [rightItem mas_makeConstraints:^(MASConstraintMaker *make) { 54 | make.right.equalTo(self.mas_right); 55 | make.top.equalTo(self.mas_top); 56 | make.height.mas_equalTo(itemWidth); 57 | make.width.mas_equalTo(itemWidth); 58 | }]; 59 | } 60 | 61 | - (void)configureLeftExpandItem { 62 | 63 | CGFloat itemWidth = CGRectGetHeight(self.frame) - CGRectGetHeight(self.indicatorView.frame); 64 | CGRect leftItemFrame = CGRectMake(0, 0, itemWidth, itemWidth); 65 | UIButton *leftItem = [UIButton buttonWithType:UIButtonTypeCustom]; 66 | UIImage *backImage = [[UIImage imageNamed:@"back"]imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate]; 67 | leftItem.frame = leftItemFrame; 68 | [leftItem setTintColor:self.itemSelectedColor]; 69 | [leftItem setBackgroundColor:[UIColor colorWithWhite:1.0 alpha:0.8]]; 70 | [leftItem setImage:backImage forState:UIControlStateNormal]; 71 | [leftItem addTarget:self action:@selector(selectLeftItem:) forControlEvents:UIControlEventTouchUpInside]; 72 | leftItem.selected = NO; 73 | [self addSubview:leftItem]; 74 | //self.leftItem = leftItem; 75 | } 76 | 77 | - (void)autoLayoutItem { 78 | 79 | if (self.isUseRightExpandItem) { 80 | /* [self.rightItem mas_makeConstraints:^(MASConstraintMaker *make) { 81 | // make.right.equalTo(self.mas_right); 82 | }];*/ 83 | 84 | } 85 | 86 | if (self.isUseLeftExpandItem) { 87 | 88 | } 89 | 90 | } 91 | 92 | - (void)selectRightItem:(UIButton *)button { 93 | 94 | if (self.delegate && [self.delegate respondsToSelector:@selector(topBarView:didSelectRightExpandItem:)]) { 95 | [self.delegate topBarView:self didSelectRightExpandItem:button]; 96 | } 97 | 98 | } 99 | 100 | - (void)selectLeftItem:(UIButton *)button { 101 | 102 | if (self.delegate && [self.delegate respondsToSelector:@selector(topBarView:didSelectLeftExpandItem:)]) { 103 | [self.delegate topBarView:self didSelectLeftExpandItem:button]; 104 | } 105 | 106 | } 107 | 108 | 109 | @end 110 | -------------------------------------------------------------------------------- /1.StarbucksCreditCardInteractionDemo/StarbucksCreditCardInteractionDemo/kit/TopBarPageVController/TopBarView.h: -------------------------------------------------------------------------------- 1 | // 2 | // TopBarView.h 3 | // TopBarPageControllerDemo 4 | // 5 | // Created by 颜建文 on 15/11/3. 6 | // Copyright © 2015年 颜建文. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "TopBarIndicatorView.h" 11 | 12 | @class TopBarView; 13 | 14 | @protocol TopBarDelegate 15 | 16 | @optional 17 | - (void)topBarView:(TopBarView *)topBarView didSelectItemAtIndex:(NSUInteger)index oldIndex:(NSUInteger)oldIndex; 18 | - (void)topBarView:(TopBarView *)topBarView didSelectLeftExpandItem:(UIButton *)leftExpandItem; 19 | - (void)topBarView:(TopBarView *)topBarView didSelectRightExpandItem:(UIButton *)rightExpandItem; 20 | @end 21 | 22 | @interface TopBarView : UIView 23 | 24 | @property (weak, nonatomic) id delegate; 25 | 26 | @property (nonatomic, strong, readonly) UIScrollView *scrollView; 27 | @property (nonatomic, strong, readonly) TopBarIndicatorView *indicatorView; 28 | @property (nonatomic, strong, readonly) NSArray *itemViewArray; 29 | @property (nonatomic, assign, readonly) NSInteger itemCount; 30 | 31 | @property (nonatomic, assign) BOOL isUseRightExpandItem; 32 | @property (nonatomic, assign) BOOL isUseLeftExpandItem; 33 | @property (nonatomic, strong, readwrite) UIFont *itemFont; 34 | @property (nonatomic, strong, readwrite) UIColor *itemNormalColor; 35 | @property (nonatomic, strong, readwrite) UIColor *itemSelectedColor; 36 | @property (nonatomic, assign, readwrite) TopBarIndicatorType topBarIndicatorType; 37 | 38 | - (instancetype)initWithFrame:(CGRect)frame itemTitleArray:(NSArray *)itemTitleArray maxItemCountOnShow:(NSUInteger)maxItemCountOnShow; 39 | 40 | /** 41 | * caculator top bar offset for item index 42 | * 43 | * @param index item index 44 | * 45 | * @return (CGPoint *) 46 | */ 47 | - (CGPoint)contentOffsetForSelectedItemAtIndex:(NSUInteger)index; 48 | - (void)moveOldItem:(NSUInteger)oldIndex toSelectedItem:(NSInteger) selectedIndex; 49 | - (void)moveToSelectedItem:(NSInteger) selectedIndex; 50 | - (void)updateLayout:(NSInteger) index ; 51 | 52 | @end 53 | 54 | 55 | -------------------------------------------------------------------------------- /1.StarbucksCreditCardInteractionDemo/StarbucksCreditCardInteractionDemo/kit/TopBarPageVController/TopBarView.m: -------------------------------------------------------------------------------- 1 | // 2 | // TopBarView.m 3 | // TopBarPageControllerDemo 4 | // 5 | // Created by 颜建文 on 15/11/3. 6 | // Copyright © 2015年 颜建文. All rights reserved. 7 | // 8 | 9 | #import "TopBarView.h" 10 | #import "TopBarIndicatorView.h" 11 | #import 12 | 13 | #define DEFAULT_INDICATOR_LINE_STYLE_HEIGHT 2.0 14 | #define DEFAULT_EXPANDITEM_WIDTH 40.0 15 | 16 | @interface TopBarView() 17 | 18 | @property (nonatomic, strong, readwrite) UIScrollView *scrollView; 19 | @property (nonatomic, strong, readwrite) UIView *scrolContentView; 20 | @property (nonatomic, strong, readwrite) TopBarIndicatorView *indicatorView; 21 | 22 | 23 | @property (nonatomic, strong, readwrite) NSArray *itemViewArray; 24 | @property (nonatomic, strong, readwrite) NSArray *itemTitleArray; 25 | @property (nonatomic, assign, readwrite) NSInteger itemCount; 26 | @property (nonatomic, assign, readwrite) NSInteger maxItemCountOnShow; 27 | @property (nonatomic, strong, readwrite) UIButton *leftExpandItem; 28 | @property (nonatomic, strong, readwrite) UIButton *rightExpandItem; 29 | 30 | @property (nonatomic, assign) NSInteger selectedIndex; 31 | @property (nonatomic, assign) CGFloat itemWidth; 32 | 33 | @end 34 | 35 | @implementation TopBarView 36 | 37 | #pragma mark - Public instance method 38 | 39 | - (instancetype)init { 40 | self = [super init]; 41 | if (self) { 42 | NSLog(@"init"); 43 | [self loadDefaultConfigure]; 44 | } 45 | return self; 46 | } 47 | 48 | /** 49 | * 初始化TopBarView 50 | * 51 | * @param frame 52 | * @param itemStyle 53 | * @param itemTitleArray 54 | * @param maxItemCountOnShow 55 | * 56 | * @return (TopBarView *) 57 | */ 58 | - (instancetype)initWithFrame:(CGRect)frame itemTitleArray:(NSArray *)itemTitleArray maxItemCountOnShow:(NSUInteger)maxItemCountOnShow { 59 | self = [super initWithFrame:frame]; 60 | NSLog(@"initWithFrame"); 61 | if (self) { 62 | if (itemTitleArray && itemTitleArray.count > 0) { 63 | [self loadDefaultConfigure]; 64 | self.selectedIndex = 0; 65 | self.itemCount = itemTitleArray.count; 66 | self.itemTitleArray = [itemTitleArray copy]; 67 | self.maxItemCountOnShow = maxItemCountOnShow; 68 | [self loadSubView]; 69 | } 70 | } 71 | 72 | return self; 73 | } 74 | 75 | /** 76 | * 根据item的index索引计算Top Bar的偏移 77 | * 78 | * @param index item的index索引号 79 | * 80 | * @return (CGPoint *) 偏移坐标 81 | */ 82 | - (CGPoint)contentOffsetForSelectedItemAtIndex:(NSUInteger)index { 83 | if (self.itemCount < index || self.itemCount == 1) { 84 | return CGPointZero; 85 | } else { 86 | CGFloat totalOffset = self.scrollView.contentSize.width - CGRectGetWidth(self.scrollView.frame); 87 | return CGPointMake(index * totalOffset / (self.itemCount - 1), 0.); 88 | } 89 | } 90 | 91 | - (void)moveOldItem:(NSUInteger)oldIndex toSelectedItem:(NSInteger) selectedIndex { 92 | [self.itemViewArray[oldIndex] setTitleColor:self.itemNormalColor forState:UIControlStateNormal]; 93 | [self.itemViewArray[selectedIndex] setTitleColor:self.itemSelectedColor forState:UIControlStateNormal]; 94 | CGPoint contentOffset = [self contentOffsetForSelectedItemAtIndex:selectedIndex]; 95 | [self.scrollView setContentOffset:contentOffset animated:YES]; 96 | self.indicatorView.center = CGPointMake(self.itemViewArray[selectedIndex].center.x, self.indicatorView.center.y); 97 | } 98 | 99 | - (void)moveToSelectedItem:(NSInteger) selectedIndex { 100 | 101 | for (UIButton *item in self.itemViewArray) { 102 | UIColor *titleColor = item.tag == selectedIndex ? self.itemSelectedColor : self.itemNormalColor; 103 | [item setTitleColor:titleColor forState:UIControlStateNormal]; 104 | } 105 | 106 | CGPoint contentOffset = [self contentOffsetForSelectedItemAtIndex:selectedIndex]; 107 | [self.scrollView setContentOffset:contentOffset animated:YES]; 108 | self.indicatorView.center = CGPointMake(self.itemViewArray[selectedIndex].center.x, self.indicatorView.center.y); 109 | } 110 | 111 | - (void)updateLayout:(NSInteger) index { 112 | self.scrollView.contentSize = CGSizeMake(self.itemWidth*self.itemCount, 0); 113 | 114 | for (int index = 0; index < self.itemCount; index++) { 115 | self.itemViewArray[index].frame = CGRectMake(index * self.itemWidth, 0, self.itemWidth, CGRectGetHeight(self.frame)); 116 | } 117 | 118 | CGFloat indicatorY = CGRectGetHeight(self.frame) - DEFAULT_INDICATOR_LINE_STYLE_HEIGHT; 119 | self.indicatorView.frame = CGRectMake(self.itemWidth*index, indicatorY, self.itemWidth, DEFAULT_INDICATOR_LINE_STYLE_HEIGHT); 120 | 121 | CGPoint topBarOffset = [self contentOffsetForSelectedItemAtIndex:index]; 122 | [self.scrollView setContentOffset:topBarOffset animated:YES]; 123 | } 124 | 125 | 126 | #pragma mark - Private instance method 127 | 128 | /** 129 | * 加载默认配置 130 | */ 131 | - (void)loadDefaultConfigure { 132 | NSLog(@"loadDefaultConfigure"); 133 | self.backgroundColor = [UIColor whiteColor]; 134 | 135 | //Configure Item 136 | self.itemNormalColor = [[UIColor alloc] initWithHue:0.511 saturation:0.11 brightness:0.58 alpha:1.0];//grey 137 | self.itemSelectedColor = [[UIColor alloc] initWithHue:0.986 saturation:0.6 brightness:0.89 alpha:1.0];//watermelon 138 | self.itemFont = [UIFont systemFontOfSize:16.0]; 139 | self.isUseRightExpandItem = NO; 140 | self.isUseLeftExpandItem = NO; 141 | self.topBarIndicatorType = TopBarIndicatorTypeLine; 142 | 143 | self.selectedIndex = 0; 144 | self.isUseLeftExpandItem = YES; 145 | self.isUseRightExpandItem = YES; 146 | } 147 | 148 | /** 149 | * 加载SubView 150 | */ 151 | - (void)loadSubView { 152 | 153 | self.maxItemCountOnShow = self.maxItemCountOnShow > self.itemCount ? self.itemCount : self.maxItemCountOnShow; 154 | [self addSubview: self.scrollView]; 155 | if (self.leftExpandItem) { 156 | [self addSubview:self.leftExpandItem]; 157 | } 158 | if (self.rightExpandItem) { 159 | [self addSubview:self.rightExpandItem]; 160 | } 161 | [self configureTopBarItem]; 162 | [self.scrollView addSubview:self.indicatorView]; 163 | [self layoutSubview]; 164 | //[self configureExpandItem]; 165 | } 166 | 167 | 168 | #pragma mark -- Configure top bar item 169 | 170 | /** 171 | * 配置TopBarItem 172 | */ 173 | - (void)configureTopBarItem { 174 | 175 | NSMutableArray *mutableItemViews = [NSMutableArray arrayWithCapacity:self.itemCount]; 176 | CGFloat buttonHeight = CGRectGetHeight(self.frame); 177 | 178 | for (NSUInteger index = 0; index < self.itemCount; index++) { 179 | CGRect buttonFrame = CGRectMake(index * self.itemWidth, 0, self.itemWidth, buttonHeight); 180 | UIButton *itemButton = [[UIButton alloc]initWithFrame: buttonFrame]; 181 | itemButton.tag = index; 182 | [itemButton addTarget:self action:@selector(selectItem:) forControlEvents:UIControlEventTouchUpInside]; 183 | 184 | NSString *itemString = self.itemTitleArray[index]; 185 | UIColor *itemColor = (index == 0) ? self.itemSelectedColor : self.itemNormalColor; 186 | 187 | [itemButton setTitle:itemString forState:UIControlStateNormal]; 188 | [itemButton.titleLabel setFont:self.itemFont]; 189 | [itemButton setTitleColor: itemColor forState:UIControlStateNormal]; 190 | 191 | [self.scrollView addSubview:itemButton]; 192 | [mutableItemViews addObject:itemButton]; 193 | } 194 | 195 | self.itemViewArray = [NSArray arrayWithArray:mutableItemViews]; 196 | 197 | } 198 | 199 | - (void)layoutSubview { 200 | 201 | 202 | [self.scrollView mas_makeConstraints:^(MASConstraintMaker *make) { 203 | //make.edges.equalTo(self); 204 | make.left.equalTo(self).offset(self.isUseLeftExpandItem ? DEFAULT_EXPANDITEM_WIDTH : 0); 205 | make.right.equalTo(self).offset(self.isUseRightExpandItem ? -DEFAULT_EXPANDITEM_WIDTH : 0); 206 | make.top.equalTo(self); 207 | make.bottom.equalTo(self); 208 | }]; 209 | 210 | if (self.isUseLeftExpandItem) { 211 | 212 | [self.leftExpandItem mas_makeConstraints:^(MASConstraintMaker *make) { 213 | make.left.equalTo(self); 214 | make.top.equalTo(self); 215 | make.bottom.equalTo(self).offset(-DEFAULT_INDICATOR_LINE_STYLE_HEIGHT); 216 | make.right.equalTo(self.scrollView.mas_left); 217 | }]; 218 | } 219 | 220 | if (self.isUseRightExpandItem) { 221 | [self.rightExpandItem mas_makeConstraints:^(MASConstraintMaker *make) { 222 | make.left.equalTo(self.scrollView.mas_right); 223 | make.top.equalTo(self); 224 | make.bottom.equalTo(self).offset(-DEFAULT_INDICATOR_LINE_STYLE_HEIGHT); 225 | make.right.equalTo(self); 226 | }]; 227 | } 228 | 229 | } 230 | 231 | #pragma mark - Events respone 232 | 233 | - (void)selectItem:(UIButton *)button { 234 | if (self.delegate && [self.delegate respondsToSelector:@selector(topBarView:didSelectItemAtIndex:oldIndex:)]) { 235 | [self.delegate topBarView:self didSelectItemAtIndex:button.tag oldIndex:self.selectedIndex]; 236 | } else { 237 | [self moveOldItem:self.selectedIndex toSelectedItem:button.tag]; 238 | } 239 | self.selectedIndex = button.tag; 240 | } 241 | 242 | - (void)clickRightItem:(UIButton *)button { 243 | NSLog(@"clickLeftItem"); 244 | if (self.delegate && [self.delegate respondsToSelector:@selector(topBarView:didSelectRightExpandItem:)]) { 245 | [self.delegate topBarView:self didSelectRightExpandItem:button]; 246 | } 247 | 248 | } 249 | 250 | - (void)clickLeftItem:(UIButton *)button { 251 | NSLog(@"clickRightItem"); 252 | if (self.delegate && [self.delegate respondsToSelector:@selector(topBarView:didSelectLeftExpandItem:)]) { 253 | [self.delegate topBarView:self didSelectLeftExpandItem:button]; 254 | } 255 | 256 | } 257 | 258 | #pragma mark - getters and setters 259 | 260 | 261 | - (CGFloat)itemWidth { 262 | return CGRectGetWidth(self.bounds) / self.maxItemCountOnShow; 263 | } 264 | 265 | - (void)setItemFont:(UIFont *)itemFont 266 | { 267 | if (!itemFont) { 268 | return; 269 | } 270 | 271 | _itemFont = itemFont; 272 | for (UIButton *itemButton in self.itemViewArray) { 273 | [itemButton.titleLabel setFont:itemFont]; 274 | } 275 | } 276 | 277 | - (void)setItemNormalColor:(UIColor *)itemNormalColor { 278 | 279 | if (!itemNormalColor) { 280 | return; 281 | } 282 | 283 | _itemNormalColor = itemNormalColor; 284 | for (UIButton *itemButton in self.itemViewArray) { 285 | if (itemButton.tag != self.selectedIndex) { 286 | [itemButton setTitleColor:itemNormalColor forState:UIControlStateNormal]; 287 | } 288 | } 289 | } 290 | 291 | - (void)setItemSelectedColor:(UIColor *)itemSelectedColor { 292 | 293 | if (!itemSelectedColor) { 294 | return; 295 | } 296 | 297 | _itemSelectedColor = itemSelectedColor; 298 | [self.itemViewArray[self.selectedIndex] setTitleColor:itemSelectedColor forState:UIControlStateNormal]; 299 | } 300 | 301 | - (UIScrollView *)scrollView { 302 | 303 | if (!_scrollView) { 304 | UIScrollView *topBarScrollView = [[UIScrollView alloc]init]; 305 | topBarScrollView.contentSize = CGSizeMake(self.itemWidth * self.itemCount, 0); 306 | topBarScrollView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight; 307 | topBarScrollView.showsVerticalScrollIndicator = NO; 308 | topBarScrollView.showsHorizontalScrollIndicator = NO; 309 | _scrollView = topBarScrollView; 310 | } 311 | 312 | return _scrollView; 313 | } 314 | 315 | - (UIView *)scrolContentView { 316 | 317 | if (!_scrolContentView) { 318 | _scrolContentView = [[UIScrollView alloc] init]; 319 | } 320 | 321 | return _scrolContentView; 322 | } 323 | 324 | - (TopBarIndicatorView *)indicatorView { 325 | 326 | if (!_indicatorView) { 327 | 328 | CGRect indicatorFrame; 329 | 330 | if (self.topBarIndicatorType == TopBarIndicatorTypeLine) { 331 | CGFloat indicatorWidth = CGRectGetWidth(self.itemViewArray[0].frame); 332 | CGFloat indicatorY = CGRectGetHeight(self.frame) - DEFAULT_INDICATOR_LINE_STYLE_HEIGHT; 333 | indicatorFrame = CGRectMake(0, indicatorY, indicatorWidth, DEFAULT_INDICATOR_LINE_STYLE_HEIGHT); 334 | } else if (self.topBarIndicatorType == TopBarIndicatorTypeTriangle) { 335 | 336 | 337 | } 338 | 339 | TopBarIndicatorView *topBarIndicatorView = [[TopBarIndicatorView alloc] initWithFrame:indicatorFrame indicatorStyle:self.topBarIndicatorType indicatorColor:self.itemSelectedColor]; 340 | NSLog(@"topBarIndicatorView"); 341 | _indicatorView = topBarIndicatorView; 342 | } 343 | 344 | return _indicatorView; 345 | } 346 | 347 | - (UIButton *)leftExpandItem { 348 | if (!_leftExpandItem) { 349 | NSLog(@"leftExpandItem"); 350 | _leftExpandItem = [UIButton buttonWithType:UIButtonTypeCustom]; 351 | [_leftExpandItem setTitle:@"L" forState:UIControlStateNormal]; 352 | [_leftExpandItem setTitleColor:_itemSelectedColor forState:UIControlStateNormal]; 353 | [_leftExpandItem addTarget:self action:@selector(clickLeftItem:) forControlEvents:UIControlEventTouchUpInside]; 354 | } 355 | 356 | return _leftExpandItem; 357 | } 358 | 359 | - (UIButton *)rightExpandItem { 360 | if (!_rightExpandItem) { 361 | _rightExpandItem = [UIButton buttonWithType:UIButtonTypeCustom]; 362 | [_rightExpandItem setTitle:@"R" forState:UIControlStateNormal]; 363 | [_rightExpandItem setTitleColor:_itemSelectedColor forState:UIControlStateNormal]; 364 | [_rightExpandItem addTarget:self action:@selector(clickRightItem:) forControlEvents:UIControlEventTouchUpInside]; 365 | } 366 | 367 | return _rightExpandItem; 368 | } 369 | 370 | - (void)setIsUseLeftExpandItem:(BOOL)isUseLeftExpandItem { 371 | if (_isUseLeftExpandItem != isUseLeftExpandItem) { 372 | self.leftExpandItem.hidden = YES; 373 | } 374 | } 375 | 376 | - (void)setIsUseRightExpandItem:(BOOL)isUseRightExpandItem { 377 | if (_isUseRightExpandItem != isUseRightExpandItem) { 378 | self.rightExpandItem.hidden = YES; 379 | } 380 | } 381 | 382 | 383 | @end -------------------------------------------------------------------------------- /1.StarbucksCreditCardInteractionDemo/StarbucksCreditCardInteractionDemo/kit/TopBarPageVController/UIColor+Fade.h: -------------------------------------------------------------------------------- 1 | // 2 | // UIColor+Fade.h 3 | // TopBarPageControllerDemo 4 | // 5 | // Created by 颜建文 on 15/11/18. 6 | // Copyright © 2015年 颜建文. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface UIColor(Fade) 12 | + (UIColor *)moveColor:(UIColor *)color toTargetColor:(UIColor *) targetColor ratio:(CGFloat)ratio; 13 | @end 14 | -------------------------------------------------------------------------------- /1.StarbucksCreditCardInteractionDemo/StarbucksCreditCardInteractionDemo/kit/TopBarPageVController/UIColor+Fade.m: -------------------------------------------------------------------------------- 1 | // 2 | // UIColor+Fade.m 3 | // TopBarPageControllerDemo 4 | // 5 | // Created by 颜建文 on 15/11/18. 6 | // Copyright © 2015年 颜建文. All rights reserved. 7 | // 8 | 9 | #import "UIColor+Fade.h" 10 | 11 | @implementation UIColor(Fade) 12 | /** 13 | * Color fade base on HSB 14 | * 15 | * @param color current color 16 | * @param targetColor target color 17 | * @param ratio 18 | * 19 | * @return ratio color 20 | */ 21 | + (UIColor *)moveColor:(UIColor *)color toTargetColor:(UIColor *) targetColor ratio:(CGFloat)ratio { 22 | 23 | CGFloat currentColorHue; 24 | CGFloat currentColorSta; 25 | CGFloat currentColorBri; 26 | 27 | CGFloat targetColorHue; 28 | CGFloat targetColorSta; 29 | CGFloat targetColorBri; 30 | 31 | CGFloat ratioColorHue; 32 | CGFloat ratioColorSta; 33 | CGFloat ratioColorBri; 34 | 35 | [color getHue:¤tColorHue saturation:¤tColorSta brightness:¤tColorBri alpha:nil]; 36 | [targetColor getHue:&targetColorHue saturation:&targetColorSta brightness:&targetColorBri alpha:nil]; 37 | 38 | ratioColorHue = currentColorHue-(currentColorHue-targetColorHue)*(ratio > 1 ? 1: ratio); 39 | ratioColorSta = currentColorSta-(currentColorSta-targetColorSta)*(ratio > 1 ? 1: ratio); 40 | ratioColorBri = currentColorBri-(currentColorBri-targetColorBri)*(ratio > 1 ? 1: ratio); 41 | 42 | UIColor *ratioColor = [[UIColor alloc]initWithHue:ratioColorHue saturation:ratioColorSta brightness:ratioColorBri alpha:1.0]; 43 | return ratioColor; 44 | 45 | } 46 | @end 47 | -------------------------------------------------------------------------------- /1.StarbucksCreditCardInteractionDemo/StarbucksCreditCardInteractionDemo/kit/YanBannerView/YanBannerView.h: -------------------------------------------------------------------------------- 1 | // 2 | // YanBannerView.h 3 | // YanBannerViewDemo 4 | // 5 | // Created by 颜建文 on 16/1/6. 6 | // Copyright © 2016年 颜建文. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "YanBannerViewCell.h" 11 | 12 | @class YanBannerView; 13 | 14 | @protocol YanBannerViewDelegate 15 | 16 | @required 17 | - (NSUInteger)numberOfBannerCellInYanBannerView:(YanBannerView *)yanBannerView; 18 | - (YanBannerViewCell *)yanBannerView:(YanBannerView *)yanBannerView cellForIndex:(NSInteger)index; 19 | 20 | @optional 21 | - (CGFloat)widthOfBannerCellInYanBannerView:(YanBannerView *)yanBannerView; 22 | - (CGFloat)offsetOfPageControl:(YanBannerView *)yanBannerView; 23 | 24 | @end 25 | 26 | @interface YanBannerView : UIView 27 | 28 | @property (nonatomic, weak) id delegate; 29 | @property (nonatomic, strong, readonly) UIPageControl *pageControl; 30 | @property (nonatomic, assign) BOOL isAnimated; 31 | @property (nonatomic, assign) NSUInteger startPage; 32 | 33 | - (void)startBannerAutoSwitchWithTimeInterval:(NSTimeInterval) timeInterval; 34 | - (void)stopBannerAutoSwitch; 35 | - (void)reloadYanBannerView; 36 | - (void)moveToPage:(NSInteger)pageNumber; 37 | 38 | @end 39 | -------------------------------------------------------------------------------- /1.StarbucksCreditCardInteractionDemo/StarbucksCreditCardInteractionDemo/kit/YanBannerView/YanBannerView.m: -------------------------------------------------------------------------------- 1 | // 2 | // YanBannerView.m 3 | // YanBannerViewDemo 4 | // 5 | // Created by 颜建文 on 16/1/6. 6 | // Copyright © 2016年 颜建文. All rights reserved. 7 | // 8 | 9 | #import "YanBannerView.h" 10 | #import 11 | 12 | #define DEFAULT_PAGECONTROL_OFFSET_WITH_BOTTOM 36.0 13 | 14 | @interface YanBannerView() 15 | 16 | @property (nonatomic, strong)UIScrollView *scrollView; 17 | @property (nonatomic, strong)UIView *scrollContentView; 18 | @property (nonatomic, strong, readwrite)UIPageControl *pageControl; 19 | 20 | @property (nonatomic, strong)NSMutableArray *bannerList; 21 | @property (nonatomic, strong)NSTimer *timer; 22 | @property (nonatomic, assign)NSTimeInterval scheduledTime; 23 | @property (nonatomic, assign)NSInteger currentBannerIndex; 24 | @property (nonatomic, assign)NSInteger bannerCount; 25 | @property (nonatomic, assign)CGFloat bannerWidth; 26 | @property (nonatomic, assign)NSInteger currentPage; 27 | 28 | @end 29 | 30 | @implementation YanBannerView 31 | 32 | @synthesize delegate = _delegate; 33 | 34 | #pragma mark - life cycle 35 | 36 | - (instancetype)init { 37 | self = [super init]; 38 | if (self) { 39 | [self loadSubView]; 40 | } 41 | return self; 42 | } 43 | 44 | - (instancetype)initWithFrame:(CGRect)frame { 45 | self = [super initWithFrame:frame]; 46 | if (self) { 47 | [self loadSubView]; 48 | } 49 | return self; 50 | } 51 | 52 | - (instancetype)initWithCoder:(NSCoder *)aDecoder { 53 | self = [super initWithCoder:aDecoder]; 54 | if (self) { 55 | [self loadSubView]; 56 | } 57 | return self; 58 | } 59 | 60 | - (void)dealloc { 61 | if (self.timer) { 62 | [self.timer invalidate]; 63 | } 64 | } 65 | 66 | - (void)loadSubView { 67 | self.isAnimated = YES; 68 | [self addSubview:self.scrollView]; 69 | [self.scrollView addSubview:self.scrollContentView]; 70 | [self addSubview:self.pageControl]; 71 | [self bringSubviewToFront:self.pageControl]; 72 | } 73 | 74 | #pragma mark - public method 75 | 76 | - (void)startBannerAutoSwitchWithTimeInterval:(NSTimeInterval) timeInterval { 77 | if (timeInterval > 0) { 78 | if (!self.timer && self.bannerCount > 1) { 79 | self.scheduledTime = timeInterval; 80 | self.timer = [NSTimer scheduledTimerWithTimeInterval:timeInterval target:self selector:@selector(switchBanner:) userInfo:nil repeats:YES]; 81 | } 82 | } 83 | } 84 | 85 | - (void)stopBannerAutoSwitch { 86 | if (self.timer) { 87 | [self.timer invalidate]; 88 | self.timer = nil; 89 | } 90 | } 91 | 92 | - (void)reloadYanBannerView { 93 | self.bannerCount = [self numberOfBannerCellInYanBannerView:self]; 94 | [self.pageControl setNumberOfPages:self.bannerCount]; 95 | self.bannerWidth = [self widthOfBannerCellInYanBannerView:self]; 96 | self.bannerList = nil; 97 | //add cell 98 | //step1 - for cycle add last view at first 99 | if (self.bannerCount > 1) { 100 | YanBannerViewCell *cell = [self yanBannerView:self cellForIndex:self.bannerCount-1]; 101 | [self.scrollContentView addSubview:cell]; 102 | [self.bannerList addObject:cell]; 103 | } 104 | //step2 - add cell 105 | for (NSInteger index = 0; index < self.bannerCount; index++) { 106 | YanBannerViewCell *cell = [self yanBannerView:self cellForIndex:index]; 107 | if(cell == nil){ 108 | 109 | } 110 | [self.scrollContentView addSubview:cell]; 111 | [self.bannerList addObject:cell]; 112 | } 113 | //step3 - for cycle add first view at first 114 | if (self.bannerCount > 1) { 115 | YanBannerViewCell *cell = [self yanBannerView:self cellForIndex:0]; 116 | [self.scrollContentView addSubview:cell]; 117 | [self.bannerList addObject:cell]; 118 | } 119 | //autolayout 120 | [self autolayoutSubview]; 121 | 122 | } 123 | 124 | - (void)autolayoutSubview { 125 | 126 | [self.scrollView mas_makeConstraints:^(MASConstraintMaker *make) { 127 | make.edges.equalTo(self); 128 | }]; 129 | 130 | [self.pageControl mas_makeConstraints:^(MASConstraintMaker *make) { 131 | make.bottom.equalTo(self.mas_bottom).with.offset(-[self offsetOfPageControl:self]); 132 | make.centerX.equalTo(self.mas_centerX); 133 | }]; 134 | 135 | [self.scrollContentView mas_makeConstraints:^(MASConstraintMaker *make) { 136 | make.edges.equalTo(self.scrollView); 137 | make.topMargin.equalTo(self.mas_topMargin); 138 | make.bottomMargin.equalTo(self.mas_bottomMargin); 139 | }]; 140 | 141 | 142 | YanBannerViewCell *lastCell = nil; 143 | 144 | for(YanBannerViewCell *cell in self.bannerList) { 145 | 146 | [cell mas_makeConstraints:^(MASConstraintMaker *make) { 147 | make.top.and.bottom.equalTo(self.scrollContentView); 148 | make.width.mas_equalTo(@(self.bannerWidth)); 149 | if (lastCell) { 150 | make.left.mas_equalTo(lastCell.mas_right); 151 | } else { 152 | make.left.mas_equalTo(self.scrollContentView.mas_left); 153 | } 154 | }]; 155 | 156 | lastCell = cell; 157 | } 158 | 159 | if (lastCell) { 160 | [self.scrollContentView mas_makeConstraints:^(MASConstraintMaker *make) { 161 | make.right.equalTo(lastCell.mas_right); 162 | }]; 163 | } 164 | 165 | } 166 | 167 | #pragma mark - events response 168 | 169 | - (void)switchBanner:(NSTimer *)timer { 170 | self.currentBannerIndex ++; 171 | [self.scrollView setContentOffset:CGPointMake(self.bannerWidth * self.currentBannerIndex, 0) animated:self.isAnimated]; 172 | } 173 | 174 | #pragma mark - scrollview delegate 175 | 176 | - (void)scrollViewDidScroll:(UIScrollView *)scrollView 177 | { 178 | NSInteger currentPage = self.currentPage; 179 | self.currentBannerIndex = currentPage; 180 | self.pageControl.currentPage = (currentPage == self.bannerCount + 1) ? 0 :currentPage-1; 181 | if (!self.isAnimated && self.pageControl.currentPage == 0) { 182 | self.currentBannerIndex = 1; 183 | } 184 | } 185 | 186 | - (void)scrollViewDidEndScrollingAnimation:(UIScrollView *)scrollView { 187 | NSInteger currentPage = self.currentPage; 188 | if (currentPage == self.bannerCount+1) { 189 | self.scrollView.contentOffset = CGPointMake(self.bannerWidth, 0); 190 | self.currentBannerIndex = 1; 191 | } else if (currentPage == 0) { 192 | self.scrollView.contentOffset = CGPointMake(self.bannerWidth * self.bannerCount, 0); 193 | self.currentBannerIndex = self.bannerCount; 194 | } 195 | } 196 | 197 | - (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView { 198 | NSInteger currentPage = self.currentPage; 199 | if (currentPage == self.bannerCount+1) { 200 | self.scrollView.contentOffset = CGPointMake(self.bannerWidth, 0); 201 | self.currentBannerIndex = 1; 202 | } else if (currentPage == 0) { 203 | self.scrollView.contentOffset = CGPointMake(self.bannerWidth * self.bannerCount, 0); 204 | self.currentBannerIndex = self.bannerCount; 205 | } 206 | } 207 | 208 | - (void)scrollViewWillBeginDragging:(UIScrollView *)scrollView 209 | { 210 | //close timer when begin dragging 211 | if (self.timer) { 212 | [self stopBannerAutoSwitch]; 213 | } 214 | } 215 | 216 | - (void)scrollViewDidEndDragging:(UIScrollView *)scrollView willDecelerate:(BOOL)decelerate 217 | { 218 | //start timer when end dragging 219 | if (self.timer) { 220 | [self startBannerAutoSwitchWithTimeInterval:self.scheduledTime]; 221 | } 222 | } 223 | 224 | #pragma mark - YanBannerViewDelegate 225 | 226 | - (NSUInteger)numberOfBannerCellInYanBannerView:(YanBannerView *)yanBannerView { 227 | 228 | NSInteger number = 0; 229 | if (self.delegate && [self.delegate respondsToSelector:@selector(numberOfBannerCellInYanBannerView:)]) { 230 | number = [self.delegate numberOfBannerCellInYanBannerView:yanBannerView]; 231 | } 232 | return number; 233 | } 234 | 235 | - (CGFloat)widthOfBannerCellInYanBannerView:(YanBannerView *)yanBannerView { 236 | 237 | CGFloat width = CGRectGetWidth([UIScreen mainScreen].bounds); 238 | if (self.delegate && [self.delegate respondsToSelector:@selector(widthOfBannerCellInYanBannerView:)]) { 239 | width = [self.delegate widthOfBannerCellInYanBannerView:yanBannerView]; 240 | } 241 | return width; 242 | } 243 | 244 | - (YanBannerViewCell *)yanBannerView:(YanBannerView *)yanBannerView cellForIndex:(NSInteger)index { 245 | 246 | YanBannerViewCell *cell = nil; 247 | if (self.delegate && [self.delegate respondsToSelector:@selector(yanBannerView:cellForIndex:)]) { 248 | cell = [self.delegate yanBannerView:yanBannerView cellForIndex:index]; 249 | } 250 | return cell; 251 | } 252 | 253 | - (CGFloat)offsetOfPageControl:(YanBannerView *)yanBannerView { 254 | CGFloat offset = DEFAULT_PAGECONTROL_OFFSET_WITH_BOTTOM; 255 | if (self.delegate && [self.delegate respondsToSelector:@selector(offsetOfPageControl:)]) { 256 | offset = [self.delegate offsetOfPageControl:yanBannerView]; 257 | } 258 | return offset; 259 | } 260 | 261 | #pragma mark - getters and setters 262 | 263 | - (NSMutableArray *)bannerList { 264 | if (!_bannerList) { 265 | _bannerList = [NSMutableArray new]; 266 | } 267 | return _bannerList; 268 | } 269 | 270 | - (UIScrollView *)scrollView { 271 | if (!_scrollView) { 272 | _scrollView = [UIScrollView new]; 273 | _scrollView.pagingEnabled = YES; 274 | _scrollView.bounces = NO; 275 | _scrollView.showsVerticalScrollIndicator = NO; 276 | _scrollView.showsHorizontalScrollIndicator = NO; 277 | _scrollView.delegate = self; 278 | } 279 | return _scrollView; 280 | } 281 | 282 | - (UIPageControl *)pageControl { 283 | if (!_pageControl) { 284 | _pageControl = [UIPageControl new]; 285 | } 286 | return _pageControl; 287 | } 288 | 289 | - (UIView *)scrollContentView { 290 | if (!_scrollContentView) { 291 | _scrollContentView = [UIView new]; 292 | } 293 | return _scrollContentView; 294 | } 295 | 296 | - (NSInteger)currentPage { 297 | return (self.scrollView.contentOffset.x + self.bannerWidth / 2) / self.bannerWidth; 298 | } 299 | 300 | - (void)setDelegate:(id)delegate { 301 | if (delegate != _delegate) { 302 | _delegate = delegate; 303 | [self reloadYanBannerView]; 304 | } 305 | } 306 | 307 | - (void)moveToPage:(NSInteger)pageNumber { 308 | 309 | if (self.bannerCount > 1 || pageNumber < self.bannerCount) { 310 | self.currentBannerIndex = 1 + pageNumber; 311 | self.scrollView.contentOffset = CGPointMake(self.bannerWidth * self.currentBannerIndex, 0); 312 | } 313 | 314 | } 315 | 316 | #pragma mark - overwrite 317 | 318 | - (void)layoutSubviews { 319 | [super layoutSubviews]; 320 | if (self.bannerCount > 1) { 321 | self.currentBannerIndex = (self.startPage < self.bannerCount) ? self.startPage + 1 : 1; 322 | self.scrollView.contentOffset = CGPointMake(self.currentBannerIndex * self.bannerWidth, 0); 323 | } else { 324 | self.currentBannerIndex = 0; 325 | } 326 | } 327 | 328 | @end 329 | -------------------------------------------------------------------------------- /1.StarbucksCreditCardInteractionDemo/StarbucksCreditCardInteractionDemo/kit/YanBannerView/YanBannerViewCell.h: -------------------------------------------------------------------------------- 1 | // 2 | // YanBannerViewCell.h 3 | // YanBannerViewDemo 4 | // 5 | // Created by 颜建文 on 16/1/6. 6 | // Copyright © 2016年 颜建文. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | 12 | 13 | @interface YanBannerViewCell : UIView 14 | 15 | 16 | @property (nonatomic, strong, readonly)UIImageView *bannerImageView; 17 | @property (nonatomic, strong, readonly)UILabel *titleLabel; 18 | 19 | @property (nonatomic, strong)UIImage *image; 20 | @property (nonatomic, copy)NSString *title; 21 | @property (nonatomic, assign)CGFloat titleHeight; 22 | 23 | @end 24 | -------------------------------------------------------------------------------- /1.StarbucksCreditCardInteractionDemo/StarbucksCreditCardInteractionDemo/kit/YanBannerView/YanBannerViewCell.m: -------------------------------------------------------------------------------- 1 | // 2 | // YanBannerViewCell.m 3 | // YanBannerViewDemo 4 | // 5 | // Created by 颜建文 on 16/1/6. 6 | // Copyright © 2016年 颜建文. All rights reserved. 7 | // 8 | 9 | #import "YanBannerViewCell.h" 10 | #import 11 | 12 | #define DEFAULT_TITLE_HEIGHT (32.0f) 13 | 14 | @interface YanBannerViewCell() 15 | 16 | @property (nonatomic, strong, readwrite)UIImageView *bannerImageView; 17 | @property (nonatomic, strong, readwrite)UILabel *titleLabel; 18 | 19 | @end 20 | 21 | @implementation YanBannerViewCell 22 | 23 | #pragma mark - getter 24 | 25 | - (UIImageView *)bannerImageView { 26 | if (!_bannerImageView) { 27 | _bannerImageView = [UIImageView new]; 28 | } 29 | return _bannerImageView; 30 | } 31 | 32 | - (UILabel *)titleLabel { 33 | if (!_titleLabel) { 34 | _titleLabel = [UILabel new]; 35 | _titleLabel.textAlignment = NSTextAlignmentCenter; 36 | _titleLabel.backgroundColor = [[UIColor alloc]initWithWhite:0.6 alpha:0.4]; 37 | _titleLabel.textColor = [UIColor whiteColor]; 38 | } 39 | return _titleLabel; 40 | } 41 | 42 | - (void)setTitle:(NSString *)title { 43 | self.titleLabel.text = [title copy];; 44 | } 45 | 46 | - (void)setImage:(UIImage *)image { 47 | self.bannerImageView.image = image; 48 | } 49 | 50 | 51 | #pragma mark - life cycle 52 | 53 | - (instancetype)init { 54 | self = [super init]; 55 | if (self) { 56 | [self loadSubView]; 57 | } 58 | return self; 59 | } 60 | 61 | - (instancetype)initWithCoder:(NSCoder *)aDecoder { 62 | self = [super initWithCoder:aDecoder]; 63 | if (self) { 64 | [self loadSubView]; 65 | } 66 | return self; 67 | } 68 | 69 | - (instancetype)initWithFrame:(CGRect)frame { 70 | self = [super initWithFrame:frame]; 71 | if (self) { 72 | [self loadSubView]; 73 | } 74 | return self; 75 | } 76 | 77 | 78 | - (void)loadSubView { 79 | self.titleHeight = DEFAULT_TITLE_HEIGHT; 80 | [self addSubview:self.bannerImageView]; 81 | [self addSubview:self.titleLabel]; 82 | [self autolayoutSubviews]; 83 | } 84 | 85 | - (void)autolayoutSubviews { 86 | [self.bannerImageView mas_makeConstraints:^(MASConstraintMaker *make) { 87 | make.edges.equalTo(self); 88 | }]; 89 | 90 | [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) { 91 | make.left.and.right.and.bottom.equalTo(self); 92 | make.top.equalTo(self.mas_bottom).offset(-self.titleHeight); 93 | }]; 94 | } 95 | 96 | 97 | @end 98 | -------------------------------------------------------------------------------- /1.StarbucksCreditCardInteractionDemo/StarbucksCreditCardInteractionDemo/kit/iCarousel/iCarousel.h: -------------------------------------------------------------------------------- 1 | // 2 | // iCarousel.h 3 | // 4 | // Version 1.8.2 5 | // 6 | // Created by Nick Lockwood on 01/04/2011. 7 | // Copyright 2011 Charcoal Design 8 | // 9 | // Distributed under the permissive zlib License 10 | // Get the latest version from here: 11 | // 12 | // https://github.com/nicklockwood/iCarousel 13 | // 14 | // This software is provided 'as-is', without any express or implied 15 | // warranty. In no event will the authors be held liable for any damages 16 | // arising from the use of this software. 17 | // 18 | // Permission is granted to anyone to use this software for any purpose, 19 | // including commercial applications, and to alter it and redistribute it 20 | // freely, subject to the following restrictions: 21 | // 22 | // 1. The origin of this software must not be misrepresented; you must not 23 | // claim that you wrote the original software. If you use this software 24 | // in a product, an acknowledgment in the product documentation would be 25 | // appreciated but is not required. 26 | // 27 | // 2. Altered source versions must be plainly marked as such, and must not be 28 | // misrepresented as being the original software. 29 | // 30 | // 3. This notice may not be removed or altered from any source distribution. 31 | // 32 | 33 | 34 | #pragma clang diagnostic push 35 | #pragma clang diagnostic ignored "-Wunknown-pragmas" 36 | #pragma clang diagnostic ignored "-Wreserved-id-macro" 37 | #pragma clang diagnostic ignored "-Wobjc-missing-property-synthesis" 38 | 39 | 40 | #import 41 | #undef weak_delegate 42 | #undef __weak_delegate 43 | #if __has_feature(objc_arc) && __has_feature(objc_arc_weak) && \ 44 | (!(defined __MAC_OS_X_VERSION_MIN_REQUIRED) || \ 45 | __MAC_OS_X_VERSION_MIN_REQUIRED >= __MAC_10_8) 46 | #define weak_delegate weak 47 | #else 48 | #define weak_delegate unsafe_unretained 49 | #endif 50 | 51 | 52 | #import 53 | #if defined USING_CHAMELEON || defined __IPHONE_OS_VERSION_MAX_ALLOWED 54 | #define ICAROUSEL_IOS 55 | #else 56 | #define ICAROUSEL_MACOS 57 | #endif 58 | 59 | 60 | #ifdef ICAROUSEL_IOS 61 | #import 62 | #else 63 | #import 64 | typedef NSView UIView; 65 | #endif 66 | 67 | 68 | typedef NS_ENUM(NSInteger, iCarouselType) 69 | { 70 | iCarouselTypeLinear = 0, 71 | iCarouselTypeRotary, 72 | iCarouselTypeInvertedRotary, 73 | iCarouselTypeCylinder, 74 | iCarouselTypeInvertedCylinder, 75 | iCarouselTypeWheel, 76 | iCarouselTypeInvertedWheel, 77 | iCarouselTypeCoverFlow, 78 | iCarouselTypeCoverFlow2, 79 | iCarouselTypeTimeMachine, 80 | iCarouselTypeInvertedTimeMachine, 81 | iCarouselTypeCustom 82 | }; 83 | 84 | 85 | typedef NS_ENUM(NSInteger, iCarouselOption) 86 | { 87 | iCarouselOptionWrap = 0, 88 | iCarouselOptionShowBackfaces, 89 | iCarouselOptionOffsetMultiplier, 90 | iCarouselOptionVisibleItems, 91 | iCarouselOptionCount, 92 | iCarouselOptionArc, 93 | iCarouselOptionAngle, 94 | iCarouselOptionRadius, 95 | iCarouselOptionTilt, 96 | iCarouselOptionSpacing, 97 | iCarouselOptionFadeMin, 98 | iCarouselOptionFadeMax, 99 | iCarouselOptionFadeRange, 100 | iCarouselOptionFadeMinAlpha 101 | }; 102 | 103 | 104 | NS_ASSUME_NONNULL_BEGIN 105 | 106 | @protocol iCarouselDataSource, iCarouselDelegate; 107 | 108 | @interface iCarousel : UIView 109 | 110 | @property (nonatomic, weak_delegate) IBOutlet __nullable id dataSource; 111 | @property (nonatomic, weak_delegate) IBOutlet __nullable id delegate; 112 | @property (nonatomic, assign) iCarouselType type; 113 | @property (nonatomic, assign) CGFloat perspective; 114 | @property (nonatomic, assign) CGFloat decelerationRate; 115 | @property (nonatomic, assign) CGFloat scrollSpeed; 116 | @property (nonatomic, assign) CGFloat bounceDistance; 117 | @property (nonatomic, assign, getter = isScrollEnabled) BOOL scrollEnabled; 118 | @property (nonatomic, assign, getter = isPagingEnabled) BOOL pagingEnabled; 119 | @property (nonatomic, assign, getter = isVertical) BOOL vertical; 120 | @property (nonatomic, readonly, getter = isWrapEnabled) BOOL wrapEnabled; 121 | @property (nonatomic, assign) BOOL bounces; 122 | @property (nonatomic, assign) CGFloat scrollOffset; 123 | @property (nonatomic, readonly) CGFloat offsetMultiplier; 124 | @property (nonatomic, assign) CGSize contentOffset; 125 | @property (nonatomic, assign) CGSize viewpointOffset; 126 | @property (nonatomic, readonly) NSInteger numberOfItems; 127 | @property (nonatomic, readonly) NSInteger numberOfPlaceholders; 128 | @property (nonatomic, assign) NSInteger currentItemIndex; 129 | @property (nonatomic, strong, readonly) UIView * __nullable currentItemView; 130 | @property (nonatomic, strong, readonly) NSArray *indexesForVisibleItems; 131 | @property (nonatomic, readonly) NSInteger numberOfVisibleItems; 132 | @property (nonatomic, strong, readonly) NSArray *visibleItemViews; 133 | @property (nonatomic, readonly) CGFloat itemWidth; 134 | @property (nonatomic, strong, readonly) UIView *contentView; 135 | @property (nonatomic, readonly) CGFloat toggle; 136 | @property (nonatomic, assign) CGFloat autoscroll; 137 | @property (nonatomic, assign) BOOL stopAtItemBoundary; 138 | @property (nonatomic, assign) BOOL scrollToItemBoundary; 139 | @property (nonatomic, assign) BOOL ignorePerpendicularSwipes; 140 | @property (nonatomic, assign) BOOL centerItemWhenSelected; 141 | @property (nonatomic, readonly, getter = isDragging) BOOL dragging; 142 | @property (nonatomic, readonly, getter = isDecelerating) BOOL decelerating; 143 | @property (nonatomic, readonly, getter = isScrolling) BOOL scrolling; 144 | 145 | - (void)scrollByOffset:(CGFloat)offset duration:(NSTimeInterval)duration; 146 | - (void)scrollToOffset:(CGFloat)offset duration:(NSTimeInterval)duration; 147 | - (void)scrollByNumberOfItems:(NSInteger)itemCount duration:(NSTimeInterval)duration; 148 | - (void)scrollToItemAtIndex:(NSInteger)index duration:(NSTimeInterval)duration; 149 | - (void)scrollToItemAtIndex:(NSInteger)index animated:(BOOL)animated; 150 | 151 | - (nullable UIView *)itemViewAtIndex:(NSInteger)index; 152 | - (NSInteger)indexOfItemView:(UIView *)view; 153 | - (NSInteger)indexOfItemViewOrSubview:(UIView *)view; 154 | - (CGFloat)offsetForItemAtIndex:(NSInteger)index; 155 | - (nullable UIView *)itemViewAtPoint:(CGPoint)point; 156 | 157 | - (void)removeItemAtIndex:(NSInteger)index animated:(BOOL)animated; 158 | - (void)insertItemAtIndex:(NSInteger)index animated:(BOOL)animated; 159 | - (void)reloadItemAtIndex:(NSInteger)index animated:(BOOL)animated; 160 | 161 | - (void)reloadData; 162 | 163 | @end 164 | 165 | 166 | @protocol iCarouselDataSource 167 | 168 | - (NSInteger)numberOfItemsInCarousel:(iCarousel *)carousel; 169 | - (UIView *)carousel:(iCarousel *)carousel viewForItemAtIndex:(NSInteger)index reusingView:(nullable UIView *)view; 170 | 171 | @optional 172 | 173 | - (NSInteger)numberOfPlaceholdersInCarousel:(iCarousel *)carousel; 174 | - (UIView *)carousel:(iCarousel *)carousel placeholderViewAtIndex:(NSInteger)index reusingView:(nullable UIView *)view; 175 | 176 | @end 177 | 178 | 179 | @protocol iCarouselDelegate 180 | @optional 181 | 182 | - (void)carouselWillBeginScrollingAnimation:(iCarousel *)carousel; 183 | - (void)carouselDidEndScrollingAnimation:(iCarousel *)carousel; 184 | - (void)carouselDidScroll:(iCarousel *)carousel; 185 | - (void)carouselCurrentItemIndexDidChange:(iCarousel *)carousel; 186 | - (void)carouselWillBeginDragging:(iCarousel *)carousel; 187 | - (void)carouselDidEndDragging:(iCarousel *)carousel willDecelerate:(BOOL)decelerate; 188 | - (void)carouselWillBeginDecelerating:(iCarousel *)carousel; 189 | - (void)carouselDidEndDecelerating:(iCarousel *)carousel; 190 | 191 | - (BOOL)carousel:(iCarousel *)carousel shouldSelectItemAtIndex:(NSInteger)index; 192 | - (void)carousel:(iCarousel *)carousel didSelectItemAtIndex:(NSInteger)index; 193 | 194 | - (CGFloat)carouselItemWidth:(iCarousel *)carousel; 195 | - (CATransform3D)carousel:(iCarousel *)carousel itemTransformForOffset:(CGFloat)offset baseTransform:(CATransform3D)transform; 196 | - (CGFloat)carousel:(iCarousel *)carousel valueForOption:(iCarouselOption)option withDefault:(CGFloat)value; 197 | 198 | @end 199 | 200 | NS_ASSUME_NONNULL_END 201 | 202 | #pragma clang diagnostic pop 203 | 204 | -------------------------------------------------------------------------------- /1.StarbucksCreditCardInteractionDemo/StarbucksCreditCardInteractionDemo/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // StarbucksCreditCardInteractionDemo 4 | // 5 | // Created by 颜建文 on 16/5/28. 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 | -------------------------------------------------------------------------------- /2.CrossFadePage-swift/CrossFadeLoginPage.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 7EB0D6451D240E7A005B292D /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7EB0D6441D240E7A005B292D /* AppDelegate.swift */; }; 11 | 7EB0D6471D240E7A005B292D /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7EB0D6461D240E7A005B292D /* ViewController.swift */; }; 12 | 7EB0D64A1D240E7A005B292D /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 7EB0D6481D240E7A005B292D /* Main.storyboard */; }; 13 | 7EB0D64C1D240E7A005B292D /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 7EB0D64B1D240E7A005B292D /* Assets.xcassets */; }; 14 | 7EB0D64F1D240E7A005B292D /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 7EB0D64D1D240E7A005B292D /* LaunchScreen.storyboard */; }; 15 | 7EB0D6591D240EC7005B292D /* CrossfadingImageView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7EB0D6581D240EC7005B292D /* CrossfadingImageView.swift */; }; 16 | 7ED7CE171D24FDD0006BF8A6 /* bg.mp3 in Resources */ = {isa = PBXBuildFile; fileRef = 7ED7CE161D24FDD0006BF8A6 /* bg.mp3 */; }; 17 | 7ED7CE191D24FDE7006BF8A6 /* AVFoundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 7ED7CE181D24FDE6006BF8A6 /* AVFoundation.framework */; }; 18 | /* End PBXBuildFile section */ 19 | 20 | /* Begin PBXFileReference section */ 21 | 7EB0D6411D240E79005B292D /* CrossFadeLoginPage.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = CrossFadeLoginPage.app; sourceTree = BUILT_PRODUCTS_DIR; }; 22 | 7EB0D6441D240E7A005B292D /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 23 | 7EB0D6461D240E7A005B292D /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = ""; }; 24 | 7EB0D6491D240E7A005B292D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 25 | 7EB0D64B1D240E7A005B292D /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 26 | 7EB0D64E1D240E7A005B292D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 27 | 7EB0D6501D240E7A005B292D /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 28 | 7EB0D6581D240EC7005B292D /* CrossfadingImageView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CrossfadingImageView.swift; sourceTree = ""; }; 29 | 7ED7CE161D24FDD0006BF8A6 /* bg.mp3 */ = {isa = PBXFileReference; lastKnownFileType = audio.mp3; path = bg.mp3; sourceTree = ""; }; 30 | 7ED7CE181D24FDE6006BF8A6 /* AVFoundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AVFoundation.framework; path = System/Library/Frameworks/AVFoundation.framework; sourceTree = SDKROOT; }; 31 | /* End PBXFileReference section */ 32 | 33 | /* Begin PBXFrameworksBuildPhase section */ 34 | 7EB0D63E1D240E79005B292D /* Frameworks */ = { 35 | isa = PBXFrameworksBuildPhase; 36 | buildActionMask = 2147483647; 37 | files = ( 38 | 7ED7CE191D24FDE7006BF8A6 /* AVFoundation.framework in Frameworks */, 39 | ); 40 | runOnlyForDeploymentPostprocessing = 0; 41 | }; 42 | /* End PBXFrameworksBuildPhase section */ 43 | 44 | /* Begin PBXGroup section */ 45 | 7EB0D6381D240E79005B292D = { 46 | isa = PBXGroup; 47 | children = ( 48 | 7ED7CE181D24FDE6006BF8A6 /* AVFoundation.framework */, 49 | 7EB0D6431D240E7A005B292D /* CrossFadeLoginPage */, 50 | 7EB0D6421D240E79005B292D /* Products */, 51 | ); 52 | sourceTree = ""; 53 | }; 54 | 7EB0D6421D240E79005B292D /* Products */ = { 55 | isa = PBXGroup; 56 | children = ( 57 | 7EB0D6411D240E79005B292D /* CrossFadeLoginPage.app */, 58 | ); 59 | name = Products; 60 | sourceTree = ""; 61 | }; 62 | 7EB0D6431D240E7A005B292D /* CrossFadeLoginPage */ = { 63 | isa = PBXGroup; 64 | children = ( 65 | 7EB0D6441D240E7A005B292D /* AppDelegate.swift */, 66 | 7EB0D6581D240EC7005B292D /* CrossfadingImageView.swift */, 67 | 7EB0D6461D240E7A005B292D /* ViewController.swift */, 68 | 7ED7CE161D24FDD0006BF8A6 /* bg.mp3 */, 69 | 7EB0D6481D240E7A005B292D /* Main.storyboard */, 70 | 7EB0D64B1D240E7A005B292D /* Assets.xcassets */, 71 | 7EB0D64D1D240E7A005B292D /* LaunchScreen.storyboard */, 72 | 7EB0D6501D240E7A005B292D /* Info.plist */, 73 | ); 74 | path = CrossFadeLoginPage; 75 | sourceTree = ""; 76 | }; 77 | /* End PBXGroup section */ 78 | 79 | /* Begin PBXNativeTarget section */ 80 | 7EB0D6401D240E79005B292D /* CrossFadeLoginPage */ = { 81 | isa = PBXNativeTarget; 82 | buildConfigurationList = 7EB0D6531D240E7A005B292D /* Build configuration list for PBXNativeTarget "CrossFadeLoginPage" */; 83 | buildPhases = ( 84 | 7EB0D63D1D240E79005B292D /* Sources */, 85 | 7EB0D63E1D240E79005B292D /* Frameworks */, 86 | 7EB0D63F1D240E79005B292D /* Resources */, 87 | ); 88 | buildRules = ( 89 | ); 90 | dependencies = ( 91 | ); 92 | name = CrossFadeLoginPage; 93 | productName = CrossFadeLoginPage; 94 | productReference = 7EB0D6411D240E79005B292D /* CrossFadeLoginPage.app */; 95 | productType = "com.apple.product-type.application"; 96 | }; 97 | /* End PBXNativeTarget section */ 98 | 99 | /* Begin PBXProject section */ 100 | 7EB0D6391D240E79005B292D /* Project object */ = { 101 | isa = PBXProject; 102 | attributes = { 103 | LastSwiftUpdateCheck = 0730; 104 | LastUpgradeCheck = 0730; 105 | ORGANIZATIONNAME = "颜建文"; 106 | TargetAttributes = { 107 | 7EB0D6401D240E79005B292D = { 108 | CreatedOnToolsVersion = 7.3.1; 109 | }; 110 | }; 111 | }; 112 | buildConfigurationList = 7EB0D63C1D240E79005B292D /* Build configuration list for PBXProject "CrossFadeLoginPage" */; 113 | compatibilityVersion = "Xcode 3.2"; 114 | developmentRegion = English; 115 | hasScannedForEncodings = 0; 116 | knownRegions = ( 117 | en, 118 | Base, 119 | ); 120 | mainGroup = 7EB0D6381D240E79005B292D; 121 | productRefGroup = 7EB0D6421D240E79005B292D /* Products */; 122 | projectDirPath = ""; 123 | projectRoot = ""; 124 | targets = ( 125 | 7EB0D6401D240E79005B292D /* CrossFadeLoginPage */, 126 | ); 127 | }; 128 | /* End PBXProject section */ 129 | 130 | /* Begin PBXResourcesBuildPhase section */ 131 | 7EB0D63F1D240E79005B292D /* Resources */ = { 132 | isa = PBXResourcesBuildPhase; 133 | buildActionMask = 2147483647; 134 | files = ( 135 | 7EB0D64F1D240E7A005B292D /* LaunchScreen.storyboard in Resources */, 136 | 7ED7CE171D24FDD0006BF8A6 /* bg.mp3 in Resources */, 137 | 7EB0D64C1D240E7A005B292D /* Assets.xcassets in Resources */, 138 | 7EB0D64A1D240E7A005B292D /* Main.storyboard in Resources */, 139 | ); 140 | runOnlyForDeploymentPostprocessing = 0; 141 | }; 142 | /* End PBXResourcesBuildPhase section */ 143 | 144 | /* Begin PBXSourcesBuildPhase section */ 145 | 7EB0D63D1D240E79005B292D /* Sources */ = { 146 | isa = PBXSourcesBuildPhase; 147 | buildActionMask = 2147483647; 148 | files = ( 149 | 7EB0D6471D240E7A005B292D /* ViewController.swift in Sources */, 150 | 7EB0D6591D240EC7005B292D /* CrossfadingImageView.swift in Sources */, 151 | 7EB0D6451D240E7A005B292D /* AppDelegate.swift in Sources */, 152 | ); 153 | runOnlyForDeploymentPostprocessing = 0; 154 | }; 155 | /* End PBXSourcesBuildPhase section */ 156 | 157 | /* Begin PBXVariantGroup section */ 158 | 7EB0D6481D240E7A005B292D /* Main.storyboard */ = { 159 | isa = PBXVariantGroup; 160 | children = ( 161 | 7EB0D6491D240E7A005B292D /* Base */, 162 | ); 163 | name = Main.storyboard; 164 | sourceTree = ""; 165 | }; 166 | 7EB0D64D1D240E7A005B292D /* LaunchScreen.storyboard */ = { 167 | isa = PBXVariantGroup; 168 | children = ( 169 | 7EB0D64E1D240E7A005B292D /* Base */, 170 | ); 171 | name = LaunchScreen.storyboard; 172 | sourceTree = ""; 173 | }; 174 | /* End PBXVariantGroup section */ 175 | 176 | /* Begin XCBuildConfiguration section */ 177 | 7EB0D6511D240E7A005B292D /* Debug */ = { 178 | isa = XCBuildConfiguration; 179 | buildSettings = { 180 | ALWAYS_SEARCH_USER_PATHS = NO; 181 | CLANG_ANALYZER_NONNULL = YES; 182 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 183 | CLANG_CXX_LIBRARY = "libc++"; 184 | CLANG_ENABLE_MODULES = YES; 185 | CLANG_ENABLE_OBJC_ARC = YES; 186 | CLANG_WARN_BOOL_CONVERSION = YES; 187 | CLANG_WARN_CONSTANT_CONVERSION = YES; 188 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 189 | CLANG_WARN_EMPTY_BODY = YES; 190 | CLANG_WARN_ENUM_CONVERSION = YES; 191 | CLANG_WARN_INT_CONVERSION = YES; 192 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 193 | CLANG_WARN_UNREACHABLE_CODE = YES; 194 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 195 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 196 | COPY_PHASE_STRIP = NO; 197 | DEBUG_INFORMATION_FORMAT = dwarf; 198 | ENABLE_STRICT_OBJC_MSGSEND = YES; 199 | ENABLE_TESTABILITY = YES; 200 | GCC_C_LANGUAGE_STANDARD = gnu99; 201 | GCC_DYNAMIC_NO_PIC = NO; 202 | GCC_NO_COMMON_BLOCKS = YES; 203 | GCC_OPTIMIZATION_LEVEL = 0; 204 | GCC_PREPROCESSOR_DEFINITIONS = ( 205 | "DEBUG=1", 206 | "$(inherited)", 207 | ); 208 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 209 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 210 | GCC_WARN_UNDECLARED_SELECTOR = YES; 211 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 212 | GCC_WARN_UNUSED_FUNCTION = YES; 213 | GCC_WARN_UNUSED_VARIABLE = YES; 214 | IPHONEOS_DEPLOYMENT_TARGET = 9.3; 215 | MTL_ENABLE_DEBUG_INFO = YES; 216 | ONLY_ACTIVE_ARCH = YES; 217 | SDKROOT = iphoneos; 218 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 219 | }; 220 | name = Debug; 221 | }; 222 | 7EB0D6521D240E7A005B292D /* Release */ = { 223 | isa = XCBuildConfiguration; 224 | buildSettings = { 225 | ALWAYS_SEARCH_USER_PATHS = NO; 226 | CLANG_ANALYZER_NONNULL = YES; 227 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 228 | CLANG_CXX_LIBRARY = "libc++"; 229 | CLANG_ENABLE_MODULES = YES; 230 | CLANG_ENABLE_OBJC_ARC = YES; 231 | CLANG_WARN_BOOL_CONVERSION = YES; 232 | CLANG_WARN_CONSTANT_CONVERSION = YES; 233 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 234 | CLANG_WARN_EMPTY_BODY = YES; 235 | CLANG_WARN_ENUM_CONVERSION = YES; 236 | CLANG_WARN_INT_CONVERSION = YES; 237 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 238 | CLANG_WARN_UNREACHABLE_CODE = YES; 239 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 240 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 241 | COPY_PHASE_STRIP = NO; 242 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 243 | ENABLE_NS_ASSERTIONS = NO; 244 | ENABLE_STRICT_OBJC_MSGSEND = YES; 245 | GCC_C_LANGUAGE_STANDARD = gnu99; 246 | GCC_NO_COMMON_BLOCKS = YES; 247 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 248 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 249 | GCC_WARN_UNDECLARED_SELECTOR = YES; 250 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 251 | GCC_WARN_UNUSED_FUNCTION = YES; 252 | GCC_WARN_UNUSED_VARIABLE = YES; 253 | IPHONEOS_DEPLOYMENT_TARGET = 9.3; 254 | MTL_ENABLE_DEBUG_INFO = NO; 255 | SDKROOT = iphoneos; 256 | VALIDATE_PRODUCT = YES; 257 | }; 258 | name = Release; 259 | }; 260 | 7EB0D6541D240E7A005B292D /* Debug */ = { 261 | isa = XCBuildConfiguration; 262 | buildSettings = { 263 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 264 | INFOPLIST_FILE = CrossFadeLoginPage/Info.plist; 265 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 266 | PRODUCT_BUNDLE_IDENTIFIER = org.yanjw.CrossFadeLoginPage; 267 | PRODUCT_NAME = "$(TARGET_NAME)"; 268 | }; 269 | name = Debug; 270 | }; 271 | 7EB0D6551D240E7A005B292D /* Release */ = { 272 | isa = XCBuildConfiguration; 273 | buildSettings = { 274 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 275 | INFOPLIST_FILE = CrossFadeLoginPage/Info.plist; 276 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 277 | PRODUCT_BUNDLE_IDENTIFIER = org.yanjw.CrossFadeLoginPage; 278 | PRODUCT_NAME = "$(TARGET_NAME)"; 279 | }; 280 | name = Release; 281 | }; 282 | /* End XCBuildConfiguration section */ 283 | 284 | /* Begin XCConfigurationList section */ 285 | 7EB0D63C1D240E79005B292D /* Build configuration list for PBXProject "CrossFadeLoginPage" */ = { 286 | isa = XCConfigurationList; 287 | buildConfigurations = ( 288 | 7EB0D6511D240E7A005B292D /* Debug */, 289 | 7EB0D6521D240E7A005B292D /* Release */, 290 | ); 291 | defaultConfigurationIsVisible = 0; 292 | defaultConfigurationName = Release; 293 | }; 294 | 7EB0D6531D240E7A005B292D /* Build configuration list for PBXNativeTarget "CrossFadeLoginPage" */ = { 295 | isa = XCConfigurationList; 296 | buildConfigurations = ( 297 | 7EB0D6541D240E7A005B292D /* Debug */, 298 | 7EB0D6551D240E7A005B292D /* Release */, 299 | ); 300 | defaultConfigurationIsVisible = 0; 301 | defaultConfigurationName = Release; 302 | }; 303 | /* End XCConfigurationList section */ 304 | }; 305 | rootObject = 7EB0D6391D240E79005B292D /* Project object */; 306 | } 307 | -------------------------------------------------------------------------------- /2.CrossFadePage-swift/CrossFadeLoginPage.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /2.CrossFadePage-swift/CrossFadeLoginPage.xcodeproj/project.xcworkspace/xcuserdata/yanjianwen.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JianwenYan/iOSFunningAnimation/a93d4e15e59b9fd396b083d4ec69da0179c934bd/2.CrossFadePage-swift/CrossFadeLoginPage.xcodeproj/project.xcworkspace/xcuserdata/yanjianwen.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /2.CrossFadePage-swift/CrossFadeLoginPage.xcodeproj/xcuserdata/yanjianwen.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 8 | 20 | 21 | 22 | 24 | 36 | 37 | 38 | 40 | 52 | 53 | 54 | 56 | 68 | 69 | 70 | 72 | 84 | 85 | 86 | 88 | 100 | 101 | 102 | 104 | 116 | 117 | 118 | 119 | 120 | -------------------------------------------------------------------------------- /2.CrossFadePage-swift/CrossFadeLoginPage.xcodeproj/xcuserdata/yanjianwen.xcuserdatad/xcschemes/CrossFadeLoginPage.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 | -------------------------------------------------------------------------------- /2.CrossFadePage-swift/CrossFadeLoginPage.xcodeproj/xcuserdata/yanjianwen.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | CrossFadeLoginPage.xcscheme 8 | 9 | orderHint 10 | 0 11 | 12 | 13 | SuppressBuildableAutocreation 14 | 15 | 7EB0D6401D240E79005B292D 16 | 17 | primary 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /2.CrossFadePage-swift/CrossFadeLoginPage/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.swift 3 | // CrossFadeLoginPage 4 | // 5 | // Created by 颜建文 on 16/6/29. 6 | // Copyright © 2016年 颜建文. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | @UIApplicationMain 12 | class AppDelegate: UIResponder, UIApplicationDelegate { 13 | 14 | var window: UIWindow? 15 | 16 | 17 | func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool { 18 | // Override point for customization after application launch. 19 | return true 20 | } 21 | 22 | func applicationWillResignActive(application: UIApplication) { 23 | // 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. 24 | // 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. 25 | } 26 | 27 | func applicationDidEnterBackground(application: UIApplication) { 28 | // 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. 29 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 30 | } 31 | 32 | func applicationWillEnterForeground(application: UIApplication) { 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 | func applicationDidBecomeActive(application: UIApplication) { 37 | // 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. 38 | } 39 | 40 | func applicationWillTerminate(application: UIApplication) { 41 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 42 | } 43 | 44 | 45 | } 46 | 47 | -------------------------------------------------------------------------------- /2.CrossFadePage-swift/CrossFadeLoginPage/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "29x29", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "29x29", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "40x40", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "40x40", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "60x60", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "60x60", 31 | "scale" : "3x" 32 | } 33 | ], 34 | "info" : { 35 | "version" : 1, 36 | "author" : "xcode" 37 | } 38 | } -------------------------------------------------------------------------------- /2.CrossFadePage-swift/CrossFadeLoginPage/Assets.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "version" : 1, 4 | "author" : "xcode" 5 | } 6 | } -------------------------------------------------------------------------------- /2.CrossFadePage-swift/CrossFadeLoginPage/Assets.xcassets/TokyoStyle1.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "scale" : "1x" 6 | }, 7 | { 8 | "idiom" : "universal", 9 | "filename" : "Magnificent Illustrations of Tokyo by Mateusz Urbanowicz 2.jpeg", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "scale" : "3x" 15 | } 16 | ], 17 | "info" : { 18 | "version" : 1, 19 | "author" : "xcode" 20 | } 21 | } -------------------------------------------------------------------------------- /2.CrossFadePage-swift/CrossFadeLoginPage/Assets.xcassets/TokyoStyle1.imageset/Magnificent Illustrations of Tokyo by Mateusz Urbanowicz 2.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JianwenYan/iOSFunningAnimation/a93d4e15e59b9fd396b083d4ec69da0179c934bd/2.CrossFadePage-swift/CrossFadeLoginPage/Assets.xcassets/TokyoStyle1.imageset/Magnificent Illustrations of Tokyo by Mateusz Urbanowicz 2.jpeg -------------------------------------------------------------------------------- /2.CrossFadePage-swift/CrossFadeLoginPage/Assets.xcassets/TokyoStyle2.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "scale" : "1x" 6 | }, 7 | { 8 | "idiom" : "universal", 9 | "filename" : "Magnificent Illustrations of Tokyo by Mateusz Urbanowicz.jpeg", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "scale" : "3x" 15 | } 16 | ], 17 | "info" : { 18 | "version" : 1, 19 | "author" : "xcode" 20 | } 21 | } -------------------------------------------------------------------------------- /2.CrossFadePage-swift/CrossFadeLoginPage/Assets.xcassets/TokyoStyle2.imageset/Magnificent Illustrations of Tokyo by Mateusz Urbanowicz.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JianwenYan/iOSFunningAnimation/a93d4e15e59b9fd396b083d4ec69da0179c934bd/2.CrossFadePage-swift/CrossFadeLoginPage/Assets.xcassets/TokyoStyle2.imageset/Magnificent Illustrations of Tokyo by Mateusz Urbanowicz.jpeg -------------------------------------------------------------------------------- /2.CrossFadePage-swift/CrossFadeLoginPage/Assets.xcassets/TokyoStyle3.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "scale" : "1x" 6 | }, 7 | { 8 | "idiom" : "universal", 9 | "filename" : "Magnificent Illustrations of Tokyo by Mateusz Urbanowicz 4.jpeg", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "scale" : "3x" 15 | } 16 | ], 17 | "info" : { 18 | "version" : 1, 19 | "author" : "xcode" 20 | } 21 | } -------------------------------------------------------------------------------- /2.CrossFadePage-swift/CrossFadeLoginPage/Assets.xcassets/TokyoStyle3.imageset/Magnificent Illustrations of Tokyo by Mateusz Urbanowicz 4.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JianwenYan/iOSFunningAnimation/a93d4e15e59b9fd396b083d4ec69da0179c934bd/2.CrossFadePage-swift/CrossFadeLoginPage/Assets.xcassets/TokyoStyle3.imageset/Magnificent Illustrations of Tokyo by Mateusz Urbanowicz 4.jpeg -------------------------------------------------------------------------------- /2.CrossFadePage-swift/CrossFadeLoginPage/Assets.xcassets/TokyoStyle4.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "scale" : "1x" 6 | }, 7 | { 8 | "idiom" : "universal", 9 | "filename" : "Magnificent Illustrations of Tokyo by Mateusz Urbanowicz 5.jpeg", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "scale" : "3x" 15 | } 16 | ], 17 | "info" : { 18 | "version" : 1, 19 | "author" : "xcode" 20 | } 21 | } -------------------------------------------------------------------------------- /2.CrossFadePage-swift/CrossFadeLoginPage/Assets.xcassets/TokyoStyle4.imageset/Magnificent Illustrations of Tokyo by Mateusz Urbanowicz 5.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JianwenYan/iOSFunningAnimation/a93d4e15e59b9fd396b083d4ec69da0179c934bd/2.CrossFadePage-swift/CrossFadeLoginPage/Assets.xcassets/TokyoStyle4.imageset/Magnificent Illustrations of Tokyo by Mateusz Urbanowicz 5.jpeg -------------------------------------------------------------------------------- /2.CrossFadePage-swift/CrossFadeLoginPage/Assets.xcassets/TokyoStyle5.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "scale" : "1x" 6 | }, 7 | { 8 | "idiom" : "universal", 9 | "filename" : "Magnificent Illustrations of Tokyo by Mateusz Urbanowicz 6.jpeg", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "scale" : "3x" 15 | } 16 | ], 17 | "info" : { 18 | "version" : 1, 19 | "author" : "xcode" 20 | } 21 | } -------------------------------------------------------------------------------- /2.CrossFadePage-swift/CrossFadeLoginPage/Assets.xcassets/TokyoStyle5.imageset/Magnificent Illustrations of Tokyo by Mateusz Urbanowicz 6.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JianwenYan/iOSFunningAnimation/a93d4e15e59b9fd396b083d4ec69da0179c934bd/2.CrossFadePage-swift/CrossFadeLoginPage/Assets.xcassets/TokyoStyle5.imageset/Magnificent Illustrations of Tokyo by Mateusz Urbanowicz 6.jpeg -------------------------------------------------------------------------------- /2.CrossFadePage-swift/CrossFadeLoginPage/Assets.xcassets/TokyoStyle6.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "scale" : "1x" 6 | }, 7 | { 8 | "idiom" : "universal", 9 | "filename" : "Group 5.png", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "scale" : "3x" 15 | } 16 | ], 17 | "info" : { 18 | "version" : 1, 19 | "author" : "xcode" 20 | } 21 | } -------------------------------------------------------------------------------- /2.CrossFadePage-swift/CrossFadeLoginPage/Assets.xcassets/TokyoStyle6.imageset/Group 5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JianwenYan/iOSFunningAnimation/a93d4e15e59b9fd396b083d4ec69da0179c934bd/2.CrossFadePage-swift/CrossFadeLoginPage/Assets.xcassets/TokyoStyle6.imageset/Group 5.png -------------------------------------------------------------------------------- /2.CrossFadePage-swift/CrossFadeLoginPage/Assets.xcassets/TokyoStyle7.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "scale" : "1x" 6 | }, 7 | { 8 | "idiom" : "universal", 9 | "filename" : "Group 5.png", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "scale" : "3x" 15 | } 16 | ], 17 | "info" : { 18 | "version" : 1, 19 | "author" : "xcode" 20 | } 21 | } -------------------------------------------------------------------------------- /2.CrossFadePage-swift/CrossFadeLoginPage/Assets.xcassets/TokyoStyle7.imageset/Group 5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JianwenYan/iOSFunningAnimation/a93d4e15e59b9fd396b083d4ec69da0179c934bd/2.CrossFadePage-swift/CrossFadeLoginPage/Assets.xcassets/TokyoStyle7.imageset/Group 5.png -------------------------------------------------------------------------------- /2.CrossFadePage-swift/CrossFadeLoginPage/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 | -------------------------------------------------------------------------------- /2.CrossFadePage-swift/CrossFadeLoginPage/Base.lproj/Main.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 33 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | -------------------------------------------------------------------------------- /2.CrossFadePage-swift/CrossFadeLoginPage/CrossfadingImageView.swift: -------------------------------------------------------------------------------- 1 | // 2 | // CrossfadingImageView.swift 3 | // CrossFadeLoginPage 4 | // 5 | // Created by 颜建文 on 16/6/29. 6 | // Copyright © 2016年 颜建文. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | class CrossfadingImageView: UIImageView { 12 | 13 | enum Direction { 14 | case Up,Down 15 | } 16 | 17 | var shouldLoopImages: Bool = true 18 | 19 | var currentIndex: NSInteger = NSNotFound { 20 | didSet { 21 | if oldValue == currentIndex { 22 | return; 23 | } 24 | 25 | if currentIndex < 0 || currentIndex >= images.count { 26 | return; 27 | } 28 | 29 | image = images[currentIndex] 30 | topView.alpha = 0; 31 | setTop() 32 | } 33 | } 34 | 35 | var images = [UIImage]() { 36 | didSet { 37 | currentIndex = 0 38 | direction = Direction.Up 39 | } 40 | } 41 | 42 | lazy var topView:UIImageView = { 43 | let view = UIImageView() 44 | view.autoresizingMask = [UIViewAutoresizing.FlexibleBottomMargin, UIViewAutoresizing.FlexibleTopMargin, UIViewAutoresizing.FlexibleLeftMargin, UIViewAutoresizing.FlexibleRightMargin] 45 | return view 46 | }() 47 | 48 | var direction: Direction = Direction.Up { 49 | didSet { 50 | if oldValue != direction { 51 | setTop() 52 | } 53 | } 54 | } 55 | 56 | override var frame: CGRect { 57 | willSet { 58 | topView.frame = newValue; 59 | } 60 | } 61 | 62 | override var bounds: CGRect { 63 | willSet { 64 | topView.bounds = newValue; 65 | } 66 | } 67 | 68 | override var contentMode: UIViewContentMode { 69 | willSet { 70 | topView.contentMode = newValue; 71 | } 72 | } 73 | 74 | 75 | required init?(coder aDecoder: NSCoder) { 76 | super.init(coder: aDecoder) 77 | currentIndex = NSNotFound; 78 | contentMode = UIViewContentMode.ScaleAspectFill; 79 | insertSubview(topView, atIndex: 0); 80 | } 81 | 82 | //tracking 83 | func up(percent:CGFloat) { 84 | if !shouldLoopImages && currentIndex == images.count - 1 { 85 | return; 86 | } 87 | 88 | direction = Direction.Up; 89 | topView.alpha = fmax(fmin(1.0, percent), 0.0) 90 | } 91 | 92 | func down(percent:CGFloat) { 93 | if !shouldLoopImages && currentIndex == 0 { 94 | return; 95 | } 96 | 97 | direction = Direction.Down 98 | topView.alpha = fmax(fmin(1.0, percent), 0.0) 99 | 100 | } 101 | 102 | //auto 103 | func startCrossFading(timeInterval:NSTimeInterval) { 104 | NSTimer.scheduledTimerWithTimeInterval(timeInterval, target: self, selector: #selector(crossFade) , userInfo: nil, repeats: true); 105 | } 106 | 107 | private func setTop() { 108 | switch direction { 109 | case Direction.Up: 110 | if currentIndex == images.count - 1 { 111 | topView.image = shouldLoopImages ? images.first : nil; 112 | } else { 113 | topView.image = images[currentIndex + 1] 114 | } 115 | break 116 | case Direction.Down: 117 | if currentIndex == 0 { 118 | topView.image = shouldLoopImages ? images.last : nil; 119 | } else { 120 | topView.image = images[currentIndex - 1] 121 | } 122 | break; 123 | } 124 | 125 | } 126 | 127 | @objc private func crossFade() { 128 | //... 129 | direction = Direction.Up 130 | self.topView.alpha = 0; 131 | UIView.animateWithDuration( 132 | 2, 133 | delay: 0, 134 | options: UIViewAnimationOptions.CurveEaseInOut, 135 | animations: { 136 | self.topView.alpha = 1; 137 | }, completion: { finished in 138 | self.updateCurrenIndex() 139 | }) 140 | 141 | } 142 | 143 | private func updateCurrenIndex() { 144 | switch direction { 145 | case Direction.Up: 146 | currentIndex = (currentIndex == images.count - 1) ? 0 : (currentIndex + 1) 147 | break 148 | case Direction.Down: 149 | currentIndex = (currentIndex == 0) ? (images.count - 1) : (currentIndex - 1) 150 | break; 151 | } 152 | } 153 | 154 | } -------------------------------------------------------------------------------- /2.CrossFadePage-swift/CrossFadeLoginPage/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | APPL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | LSRequiresIPhoneOS 24 | 25 | UILaunchStoryboardName 26 | LaunchScreen 27 | UIMainStoryboardFile 28 | Main 29 | UIRequiredDeviceCapabilities 30 | 31 | armv7 32 | 33 | UISupportedInterfaceOrientations 34 | 35 | UIInterfaceOrientationPortrait 36 | UIInterfaceOrientationLandscapeLeft 37 | UIInterfaceOrientationLandscapeRight 38 | 39 | 40 | 41 | -------------------------------------------------------------------------------- /2.CrossFadePage-swift/CrossFadeLoginPage/ViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.swift 3 | // CrossFadeLoginPage 4 | // 5 | // Created by 颜建文 on 16/6/29. 6 | // Copyright © 2016年 颜建文. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | import AVFoundation 11 | 12 | class ViewController: UIViewController { 13 | 14 | @IBOutlet weak var backgroundImageView: CrossfadingImageView! 15 | 16 | var musicPlayer = AVAudioPlayer() 17 | 18 | override func viewDidLoad() { 19 | super.viewDidLoad() 20 | // Do any additional setup after loading the view, typically from a nib. 21 | backgroundImageView.images = [ UIImage.init(named: "TokyoStyle1")!, 22 | UIImage.init(named: "TokyoStyle2")!, 23 | UIImage.init(named: "TokyoStyle3")!, 24 | UIImage.init(named: "TokyoStyle4")!, 25 | UIImage.init(named: "TokyoStyle5")!, 26 | UIImage.init(named: "TokyoStyle6")!, 27 | UIImage.init(named: "TokyoStyle7")!, 28 | ]; 29 | backgroundImageView.startCrossFading(6); 30 | playBackgroundMusic() 31 | 32 | } 33 | 34 | override func didReceiveMemoryWarning() { 35 | super.didReceiveMemoryWarning() 36 | // Dispose of any resources that can be recreated. 37 | } 38 | 39 | func playBackgroundMusic() { 40 | let musicURL:NSURL = NSBundle.mainBundle().URLForResource("bg", withExtension: "mp3")! 41 | do { 42 | try musicPlayer = AVAudioPlayer(contentsOfURL: musicURL, fileTypeHint: "mp3") 43 | musicPlayer.numberOfLoops = -1 44 | musicPlayer.prepareToPlay() 45 | musicPlayer.play() 46 | } catch let error as NSError { 47 | print("Could not create audio player: \(error)") 48 | } 49 | } 50 | 51 | } 52 | 53 | -------------------------------------------------------------------------------- /2.CrossFadePage-swift/CrossFadeLoginPage/bg.mp3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JianwenYan/iOSFunningAnimation/a93d4e15e59b9fd396b083d4ec69da0179c934bd/2.CrossFadePage-swift/CrossFadeLoginPage/bg.mp3 -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # iOSFunningAnimation 2 | some funning animation demo for iOS (from dribbble, materialup or...) 3 | 4 | ##1.StarbucksCreditCardInteractionDemo 5 | 6 | ![iOSFunningAnimation](https://github.com/JianwenYan/iOSFunningAnimation/raw/master/readme-assets/StarbucksCreditCardInteractionDemo.gif) 7 | 8 | ### animation resource from: 9 | http://www.materialup.com/posts/starbucks-credit-card-interaction-animation 10 | 11 | ### sketch resource from: 12 | https://goo.gl/vNhXjx 13 | 14 | ### Fix: 15 | In this project, i set the storyboard with w(Compact) x h(Regular) for iPhone. After pod install, storyboard will be set to w(Compact) x h(Compact) and can not see the layout. So we need to reset it: 16 | 17 | ![iOSFunningAnimation](https://github.com/JianwenYan/iOSFunningAnimation/raw/master/readme-assets/StarbucksCreditCardInteractioPayStoryboardFix.gif) 18 | 19 | 20 | ##2.CrossFadePage-Swift 21 | 22 | ![iOSFunningAnimation](https://github.com/JianwenYan/iOSFunningAnimation/raw/master/readme-assets/CrossFadePage.gif) 23 | 24 | 25 | ### picture resource from: 26 | http://www.fubiz.net/en/2016/05/27/magnificent-illustrations-of-tokyo-by-mateusz-urbanowicz/ 27 | 28 | ### CrossfadingImageView.swift base on artsy 29 | https://github.com/artsy/eigen/blob/master/Artsy/View_Controllers/Login_and_Onboarding/Onboarding_stages/2_-_Calls_to_Action/Views/ARCrossfadingImageView.m 30 | 31 | -------------------------------------------------------------------------------- /readme-assets/CrossFadePage.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JianwenYan/iOSFunningAnimation/a93d4e15e59b9fd396b083d4ec69da0179c934bd/readme-assets/CrossFadePage.gif -------------------------------------------------------------------------------- /readme-assets/StarbucksCreditCardInteractioPayStoryboardFix.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JianwenYan/iOSFunningAnimation/a93d4e15e59b9fd396b083d4ec69da0179c934bd/readme-assets/StarbucksCreditCardInteractioPayStoryboardFix.gif -------------------------------------------------------------------------------- /readme-assets/StarbucksCreditCardInteractionDemo.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JianwenYan/iOSFunningAnimation/a93d4e15e59b9fd396b083d4ec69da0179c934bd/readme-assets/StarbucksCreditCardInteractionDemo.gif --------------------------------------------------------------------------------