├── .DS_Store ├── .gitignore ├── HZBannerViewDemo ├── .DS_Store ├── HZBannerViewDemo.xcodeproj │ ├── project.pbxproj │ └── project.xcworkspace │ │ └── contents.xcworkspacedata └── HZBannerViewDemo │ ├── .DS_Store │ ├── AppDelegate.h │ ├── AppDelegate.m │ ├── Assets.xcassets │ ├── AppIcon.appiconset │ │ └── Contents.json │ ├── Contents.json │ └── defaultImage.imageset │ │ ├── Contents.json │ │ └── defaultImage@2x.jpg │ ├── Base.lproj │ ├── LaunchScreen.storyboard │ └── Main.storyboard │ ├── HZBannerView │ ├── HZBannerCell.h │ ├── HZBannerCell.m │ ├── HZBannerModel.h │ ├── HZBannerModel.m │ ├── HZBannerView.h │ ├── HZBannerView.m │ ├── HZBannerViewFlowLayout.h │ └── HZBannerViewFlowLayout.m │ ├── Info.plist │ ├── Resources │ ├── .DS_Store │ ├── DataPropertyList.plist │ └── Images │ │ ├── 1.png │ │ ├── 10.png │ │ ├── 11.png │ │ ├── 12.png │ │ ├── 13.png │ │ ├── 2.png │ │ ├── 3.png │ │ ├── 4.png │ │ ├── 5.png │ │ ├── 6.png │ │ ├── 7.png │ │ ├── 8.png │ │ └── 9.png │ ├── ViewController.h │ ├── ViewController.m │ └── main.m └── README.md /.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HughTsang/HZBannerViewDemo/3df18f2c35bf352c915f93790c22273c64694c5d/.DS_Store -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Xcode 2 | # 3 | # gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore 4 | 5 | ## Build generated 6 | build/ 7 | DerivedData/ 8 | 9 | ## Various settings 10 | *.pbxuser 11 | !default.pbxuser 12 | *.mode1v3 13 | !default.mode1v3 14 | *.mode2v3 15 | !default.mode2v3 16 | *.perspectivev3 17 | !default.perspectivev3 18 | xcuserdata/ 19 | 20 | ## Other 21 | *.moved-aside 22 | *.xcuserstate 23 | 24 | ## Obj-C/Swift specific 25 | *.hmap 26 | *.ipa 27 | *.dSYM.zip 28 | *.dSYM 29 | 30 | # CocoaPods 31 | # 32 | # We recommend against adding the Pods directory to your .gitignore. However 33 | # you should judge for yourself, the pros and cons are mentioned at: 34 | # https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control 35 | # 36 | # Pods/ 37 | 38 | # Carthage 39 | # 40 | # Add this line if you want to avoid checking in source code from Carthage dependencies. 41 | # Carthage/Checkouts 42 | 43 | Carthage/Build 44 | 45 | # fastlane 46 | # 47 | # It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the 48 | # screenshots whenever they are needed. 49 | # For more information about the recommended setup visit: 50 | # https://github.com/fastlane/fastlane/blob/master/fastlane/docs/Gitignore.md 51 | 52 | fastlane/report.xml 53 | fastlane/screenshots 54 | 55 | #Code Injection 56 | # 57 | # After new code Injection tools there's a generated folder /iOSInjectionProject 58 | # https://github.com/johnno1962/injectionforxcode 59 | 60 | iOSInjectionProject/ 61 | -------------------------------------------------------------------------------- /HZBannerViewDemo/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HughTsang/HZBannerViewDemo/3df18f2c35bf352c915f93790c22273c64694c5d/HZBannerViewDemo/.DS_Store -------------------------------------------------------------------------------- /HZBannerViewDemo/HZBannerViewDemo.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | ECAE8C9E1EA65BB10066ED62 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = ECAE8C9D1EA65BB10066ED62 /* main.m */; }; 11 | ECAE8CA11EA65BB10066ED62 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = ECAE8CA01EA65BB10066ED62 /* AppDelegate.m */; }; 12 | ECAE8CA41EA65BB10066ED62 /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = ECAE8CA31EA65BB10066ED62 /* ViewController.m */; }; 13 | ECAE8CA71EA65BB10066ED62 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = ECAE8CA51EA65BB10066ED62 /* Main.storyboard */; }; 14 | ECAE8CA91EA65BB10066ED62 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = ECAE8CA81EA65BB10066ED62 /* Assets.xcassets */; }; 15 | ECAE8CAC1EA65BB10066ED62 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = ECAE8CAA1EA65BB10066ED62 /* LaunchScreen.storyboard */; }; 16 | ECAE8D151EA65CB20066ED62 /* DataPropertyList.plist in Resources */ = {isa = PBXBuildFile; fileRef = ECAE8D061EA65CB20066ED62 /* DataPropertyList.plist */; }; 17 | ECAE8D161EA65CB20066ED62 /* 1.png in Resources */ = {isa = PBXBuildFile; fileRef = ECAE8D081EA65CB20066ED62 /* 1.png */; }; 18 | ECAE8D171EA65CB20066ED62 /* 10.png in Resources */ = {isa = PBXBuildFile; fileRef = ECAE8D091EA65CB20066ED62 /* 10.png */; }; 19 | ECAE8D181EA65CB20066ED62 /* 11.png in Resources */ = {isa = PBXBuildFile; fileRef = ECAE8D0A1EA65CB20066ED62 /* 11.png */; }; 20 | ECAE8D191EA65CB20066ED62 /* 12.png in Resources */ = {isa = PBXBuildFile; fileRef = ECAE8D0B1EA65CB20066ED62 /* 12.png */; }; 21 | ECAE8D1A1EA65CB20066ED62 /* 13.png in Resources */ = {isa = PBXBuildFile; fileRef = ECAE8D0C1EA65CB20066ED62 /* 13.png */; }; 22 | ECAE8D1B1EA65CB20066ED62 /* 2.png in Resources */ = {isa = PBXBuildFile; fileRef = ECAE8D0D1EA65CB20066ED62 /* 2.png */; }; 23 | ECAE8D1C1EA65CB20066ED62 /* 3.png in Resources */ = {isa = PBXBuildFile; fileRef = ECAE8D0E1EA65CB20066ED62 /* 3.png */; }; 24 | ECAE8D1D1EA65CB20066ED62 /* 4.png in Resources */ = {isa = PBXBuildFile; fileRef = ECAE8D0F1EA65CB20066ED62 /* 4.png */; }; 25 | ECAE8D1E1EA65CB20066ED62 /* 5.png in Resources */ = {isa = PBXBuildFile; fileRef = ECAE8D101EA65CB20066ED62 /* 5.png */; }; 26 | ECAE8D1F1EA65CB20066ED62 /* 6.png in Resources */ = {isa = PBXBuildFile; fileRef = ECAE8D111EA65CB20066ED62 /* 6.png */; }; 27 | ECAE8D201EA65CB20066ED62 /* 7.png in Resources */ = {isa = PBXBuildFile; fileRef = ECAE8D121EA65CB20066ED62 /* 7.png */; }; 28 | ECAE8D211EA65CB20066ED62 /* 8.png in Resources */ = {isa = PBXBuildFile; fileRef = ECAE8D131EA65CB20066ED62 /* 8.png */; }; 29 | ECAE8D221EA65CB20066ED62 /* 9.png in Resources */ = {isa = PBXBuildFile; fileRef = ECAE8D141EA65CB20066ED62 /* 9.png */; }; 30 | ECAE8D2C1EA669F60066ED62 /* HZBannerCell.m in Sources */ = {isa = PBXBuildFile; fileRef = ECAE8D251EA669F60066ED62 /* HZBannerCell.m */; }; 31 | ECAE8D2D1EA669F60066ED62 /* HZBannerModel.m in Sources */ = {isa = PBXBuildFile; fileRef = ECAE8D271EA669F60066ED62 /* HZBannerModel.m */; }; 32 | ECAE8D2E1EA669F60066ED62 /* HZBannerView.m in Sources */ = {isa = PBXBuildFile; fileRef = ECAE8D291EA669F60066ED62 /* HZBannerView.m */; }; 33 | ECAE8D2F1EA669F60066ED62 /* HZBannerViewFlowLayout.m in Sources */ = {isa = PBXBuildFile; fileRef = ECAE8D2B1EA669F60066ED62 /* HZBannerViewFlowLayout.m */; }; 34 | /* End PBXBuildFile section */ 35 | 36 | /* Begin PBXFileReference section */ 37 | ECAE8C991EA65BB10066ED62 /* HZBannerViewDemo.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = HZBannerViewDemo.app; sourceTree = BUILT_PRODUCTS_DIR; }; 38 | ECAE8C9D1EA65BB10066ED62 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; 39 | ECAE8C9F1EA65BB10066ED62 /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; 40 | ECAE8CA01EA65BB10066ED62 /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; }; 41 | ECAE8CA21EA65BB10066ED62 /* ViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ViewController.h; sourceTree = ""; }; 42 | ECAE8CA31EA65BB10066ED62 /* ViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ViewController.m; sourceTree = ""; }; 43 | ECAE8CA61EA65BB10066ED62 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 44 | ECAE8CA81EA65BB10066ED62 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 45 | ECAE8CAB1EA65BB10066ED62 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 46 | ECAE8CAD1EA65BB10066ED62 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 47 | ECAE8D061EA65CB20066ED62 /* DataPropertyList.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = DataPropertyList.plist; sourceTree = ""; }; 48 | ECAE8D081EA65CB20066ED62 /* 1.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = 1.png; sourceTree = ""; }; 49 | ECAE8D091EA65CB20066ED62 /* 10.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = 10.png; sourceTree = ""; }; 50 | ECAE8D0A1EA65CB20066ED62 /* 11.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = 11.png; sourceTree = ""; }; 51 | ECAE8D0B1EA65CB20066ED62 /* 12.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = 12.png; sourceTree = ""; }; 52 | ECAE8D0C1EA65CB20066ED62 /* 13.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = 13.png; sourceTree = ""; }; 53 | ECAE8D0D1EA65CB20066ED62 /* 2.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = 2.png; sourceTree = ""; }; 54 | ECAE8D0E1EA65CB20066ED62 /* 3.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = 3.png; sourceTree = ""; }; 55 | ECAE8D0F1EA65CB20066ED62 /* 4.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = 4.png; sourceTree = ""; }; 56 | ECAE8D101EA65CB20066ED62 /* 5.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = 5.png; sourceTree = ""; }; 57 | ECAE8D111EA65CB20066ED62 /* 6.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = 6.png; sourceTree = ""; }; 58 | ECAE8D121EA65CB20066ED62 /* 7.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = 7.png; sourceTree = ""; }; 59 | ECAE8D131EA65CB20066ED62 /* 8.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = 8.png; sourceTree = ""; }; 60 | ECAE8D141EA65CB20066ED62 /* 9.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = 9.png; sourceTree = ""; }; 61 | ECAE8D241EA669F60066ED62 /* HZBannerCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HZBannerCell.h; sourceTree = ""; }; 62 | ECAE8D251EA669F60066ED62 /* HZBannerCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = HZBannerCell.m; sourceTree = ""; }; 63 | ECAE8D261EA669F60066ED62 /* HZBannerModel.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HZBannerModel.h; sourceTree = ""; }; 64 | ECAE8D271EA669F60066ED62 /* HZBannerModel.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = HZBannerModel.m; sourceTree = ""; }; 65 | ECAE8D281EA669F60066ED62 /* HZBannerView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HZBannerView.h; sourceTree = ""; }; 66 | ECAE8D291EA669F60066ED62 /* HZBannerView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = HZBannerView.m; sourceTree = ""; }; 67 | ECAE8D2A1EA669F60066ED62 /* HZBannerViewFlowLayout.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HZBannerViewFlowLayout.h; sourceTree = ""; }; 68 | ECAE8D2B1EA669F60066ED62 /* HZBannerViewFlowLayout.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = HZBannerViewFlowLayout.m; sourceTree = ""; }; 69 | /* End PBXFileReference section */ 70 | 71 | /* Begin PBXFrameworksBuildPhase section */ 72 | ECAE8C961EA65BB10066ED62 /* Frameworks */ = { 73 | isa = PBXFrameworksBuildPhase; 74 | buildActionMask = 2147483647; 75 | files = ( 76 | ); 77 | runOnlyForDeploymentPostprocessing = 0; 78 | }; 79 | /* End PBXFrameworksBuildPhase section */ 80 | 81 | /* Begin PBXGroup section */ 82 | ECAE8C901EA65BB10066ED62 = { 83 | isa = PBXGroup; 84 | children = ( 85 | ECAE8C9B1EA65BB10066ED62 /* HZBannerViewDemo */, 86 | ECAE8C9A1EA65BB10066ED62 /* Products */, 87 | ); 88 | sourceTree = ""; 89 | }; 90 | ECAE8C9A1EA65BB10066ED62 /* Products */ = { 91 | isa = PBXGroup; 92 | children = ( 93 | ECAE8C991EA65BB10066ED62 /* HZBannerViewDemo.app */, 94 | ); 95 | name = Products; 96 | sourceTree = ""; 97 | }; 98 | ECAE8C9B1EA65BB10066ED62 /* HZBannerViewDemo */ = { 99 | isa = PBXGroup; 100 | children = ( 101 | ECAE8D051EA65CB20066ED62 /* Resources */, 102 | ECAE8D231EA669F60066ED62 /* HZBannerView */, 103 | ECAE8C9F1EA65BB10066ED62 /* AppDelegate.h */, 104 | ECAE8CA01EA65BB10066ED62 /* AppDelegate.m */, 105 | ECAE8CA21EA65BB10066ED62 /* ViewController.h */, 106 | ECAE8CA31EA65BB10066ED62 /* ViewController.m */, 107 | ECAE8CA51EA65BB10066ED62 /* Main.storyboard */, 108 | ECAE8CA81EA65BB10066ED62 /* Assets.xcassets */, 109 | ECAE8CAA1EA65BB10066ED62 /* LaunchScreen.storyboard */, 110 | ECAE8CAD1EA65BB10066ED62 /* Info.plist */, 111 | ECAE8C9C1EA65BB10066ED62 /* Supporting Files */, 112 | ); 113 | path = HZBannerViewDemo; 114 | sourceTree = ""; 115 | }; 116 | ECAE8C9C1EA65BB10066ED62 /* Supporting Files */ = { 117 | isa = PBXGroup; 118 | children = ( 119 | ECAE8C9D1EA65BB10066ED62 /* main.m */, 120 | ); 121 | name = "Supporting Files"; 122 | sourceTree = ""; 123 | }; 124 | ECAE8D051EA65CB20066ED62 /* Resources */ = { 125 | isa = PBXGroup; 126 | children = ( 127 | ECAE8D061EA65CB20066ED62 /* DataPropertyList.plist */, 128 | ECAE8D071EA65CB20066ED62 /* Images */, 129 | ); 130 | path = Resources; 131 | sourceTree = ""; 132 | }; 133 | ECAE8D071EA65CB20066ED62 /* Images */ = { 134 | isa = PBXGroup; 135 | children = ( 136 | ECAE8D081EA65CB20066ED62 /* 1.png */, 137 | ECAE8D091EA65CB20066ED62 /* 10.png */, 138 | ECAE8D0A1EA65CB20066ED62 /* 11.png */, 139 | ECAE8D0B1EA65CB20066ED62 /* 12.png */, 140 | ECAE8D0C1EA65CB20066ED62 /* 13.png */, 141 | ECAE8D0D1EA65CB20066ED62 /* 2.png */, 142 | ECAE8D0E1EA65CB20066ED62 /* 3.png */, 143 | ECAE8D0F1EA65CB20066ED62 /* 4.png */, 144 | ECAE8D101EA65CB20066ED62 /* 5.png */, 145 | ECAE8D111EA65CB20066ED62 /* 6.png */, 146 | ECAE8D121EA65CB20066ED62 /* 7.png */, 147 | ECAE8D131EA65CB20066ED62 /* 8.png */, 148 | ECAE8D141EA65CB20066ED62 /* 9.png */, 149 | ); 150 | path = Images; 151 | sourceTree = ""; 152 | }; 153 | ECAE8D231EA669F60066ED62 /* HZBannerView */ = { 154 | isa = PBXGroup; 155 | children = ( 156 | ECAE8D281EA669F60066ED62 /* HZBannerView.h */, 157 | ECAE8D291EA669F60066ED62 /* HZBannerView.m */, 158 | ECAE8D2A1EA669F60066ED62 /* HZBannerViewFlowLayout.h */, 159 | ECAE8D2B1EA669F60066ED62 /* HZBannerViewFlowLayout.m */, 160 | ECAE8D241EA669F60066ED62 /* HZBannerCell.h */, 161 | ECAE8D251EA669F60066ED62 /* HZBannerCell.m */, 162 | ECAE8D261EA669F60066ED62 /* HZBannerModel.h */, 163 | ECAE8D271EA669F60066ED62 /* HZBannerModel.m */, 164 | ); 165 | path = HZBannerView; 166 | sourceTree = ""; 167 | }; 168 | /* End PBXGroup section */ 169 | 170 | /* Begin PBXNativeTarget section */ 171 | ECAE8C981EA65BB10066ED62 /* HZBannerViewDemo */ = { 172 | isa = PBXNativeTarget; 173 | buildConfigurationList = ECAE8CB01EA65BB10066ED62 /* Build configuration list for PBXNativeTarget "HZBannerViewDemo" */; 174 | buildPhases = ( 175 | ECAE8C951EA65BB10066ED62 /* Sources */, 176 | ECAE8C961EA65BB10066ED62 /* Frameworks */, 177 | ECAE8C971EA65BB10066ED62 /* Resources */, 178 | ); 179 | buildRules = ( 180 | ); 181 | dependencies = ( 182 | ); 183 | name = HZBannerViewDemo; 184 | productName = HZBannerViewDemo; 185 | productReference = ECAE8C991EA65BB10066ED62 /* HZBannerViewDemo.app */; 186 | productType = "com.apple.product-type.application"; 187 | }; 188 | /* End PBXNativeTarget section */ 189 | 190 | /* Begin PBXProject section */ 191 | ECAE8C911EA65BB10066ED62 /* Project object */ = { 192 | isa = PBXProject; 193 | attributes = { 194 | LastUpgradeCheck = 0820; 195 | ORGANIZATIONNAME = Null; 196 | TargetAttributes = { 197 | ECAE8C981EA65BB10066ED62 = { 198 | CreatedOnToolsVersion = 8.2.1; 199 | ProvisioningStyle = Automatic; 200 | }; 201 | }; 202 | }; 203 | buildConfigurationList = ECAE8C941EA65BB10066ED62 /* Build configuration list for PBXProject "HZBannerViewDemo" */; 204 | compatibilityVersion = "Xcode 3.2"; 205 | developmentRegion = English; 206 | hasScannedForEncodings = 0; 207 | knownRegions = ( 208 | en, 209 | Base, 210 | ); 211 | mainGroup = ECAE8C901EA65BB10066ED62; 212 | productRefGroup = ECAE8C9A1EA65BB10066ED62 /* Products */; 213 | projectDirPath = ""; 214 | projectRoot = ""; 215 | targets = ( 216 | ECAE8C981EA65BB10066ED62 /* HZBannerViewDemo */, 217 | ); 218 | }; 219 | /* End PBXProject section */ 220 | 221 | /* Begin PBXResourcesBuildPhase section */ 222 | ECAE8C971EA65BB10066ED62 /* Resources */ = { 223 | isa = PBXResourcesBuildPhase; 224 | buildActionMask = 2147483647; 225 | files = ( 226 | ECAE8D211EA65CB20066ED62 /* 8.png in Resources */, 227 | ECAE8D1F1EA65CB20066ED62 /* 6.png in Resources */, 228 | ECAE8D1D1EA65CB20066ED62 /* 4.png in Resources */, 229 | ECAE8D1C1EA65CB20066ED62 /* 3.png in Resources */, 230 | ECAE8CAC1EA65BB10066ED62 /* LaunchScreen.storyboard in Resources */, 231 | ECAE8CA91EA65BB10066ED62 /* Assets.xcassets in Resources */, 232 | ECAE8D1B1EA65CB20066ED62 /* 2.png in Resources */, 233 | ECAE8D1A1EA65CB20066ED62 /* 13.png in Resources */, 234 | ECAE8D171EA65CB20066ED62 /* 10.png in Resources */, 235 | ECAE8D221EA65CB20066ED62 /* 9.png in Resources */, 236 | ECAE8CA71EA65BB10066ED62 /* Main.storyboard in Resources */, 237 | ECAE8D191EA65CB20066ED62 /* 12.png in Resources */, 238 | ECAE8D151EA65CB20066ED62 /* DataPropertyList.plist in Resources */, 239 | ECAE8D181EA65CB20066ED62 /* 11.png in Resources */, 240 | ECAE8D201EA65CB20066ED62 /* 7.png in Resources */, 241 | ECAE8D1E1EA65CB20066ED62 /* 5.png in Resources */, 242 | ECAE8D161EA65CB20066ED62 /* 1.png in Resources */, 243 | ); 244 | runOnlyForDeploymentPostprocessing = 0; 245 | }; 246 | /* End PBXResourcesBuildPhase section */ 247 | 248 | /* Begin PBXSourcesBuildPhase section */ 249 | ECAE8C951EA65BB10066ED62 /* Sources */ = { 250 | isa = PBXSourcesBuildPhase; 251 | buildActionMask = 2147483647; 252 | files = ( 253 | ECAE8D2F1EA669F60066ED62 /* HZBannerViewFlowLayout.m in Sources */, 254 | ECAE8CA41EA65BB10066ED62 /* ViewController.m in Sources */, 255 | ECAE8D2C1EA669F60066ED62 /* HZBannerCell.m in Sources */, 256 | ECAE8CA11EA65BB10066ED62 /* AppDelegate.m in Sources */, 257 | ECAE8C9E1EA65BB10066ED62 /* main.m in Sources */, 258 | ECAE8D2E1EA669F60066ED62 /* HZBannerView.m in Sources */, 259 | ECAE8D2D1EA669F60066ED62 /* HZBannerModel.m in Sources */, 260 | ); 261 | runOnlyForDeploymentPostprocessing = 0; 262 | }; 263 | /* End PBXSourcesBuildPhase section */ 264 | 265 | /* Begin PBXVariantGroup section */ 266 | ECAE8CA51EA65BB10066ED62 /* Main.storyboard */ = { 267 | isa = PBXVariantGroup; 268 | children = ( 269 | ECAE8CA61EA65BB10066ED62 /* Base */, 270 | ); 271 | name = Main.storyboard; 272 | sourceTree = ""; 273 | }; 274 | ECAE8CAA1EA65BB10066ED62 /* LaunchScreen.storyboard */ = { 275 | isa = PBXVariantGroup; 276 | children = ( 277 | ECAE8CAB1EA65BB10066ED62 /* Base */, 278 | ); 279 | name = LaunchScreen.storyboard; 280 | sourceTree = ""; 281 | }; 282 | /* End PBXVariantGroup section */ 283 | 284 | /* Begin XCBuildConfiguration section */ 285 | ECAE8CAE1EA65BB10066ED62 /* Debug */ = { 286 | isa = XCBuildConfiguration; 287 | buildSettings = { 288 | ALWAYS_SEARCH_USER_PATHS = NO; 289 | CLANG_ANALYZER_NONNULL = YES; 290 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 291 | CLANG_CXX_LIBRARY = "libc++"; 292 | CLANG_ENABLE_MODULES = YES; 293 | CLANG_ENABLE_OBJC_ARC = YES; 294 | CLANG_WARN_BOOL_CONVERSION = YES; 295 | CLANG_WARN_CONSTANT_CONVERSION = YES; 296 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 297 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 298 | CLANG_WARN_EMPTY_BODY = YES; 299 | CLANG_WARN_ENUM_CONVERSION = YES; 300 | CLANG_WARN_INFINITE_RECURSION = YES; 301 | CLANG_WARN_INT_CONVERSION = YES; 302 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 303 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 304 | CLANG_WARN_UNREACHABLE_CODE = YES; 305 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 306 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 307 | COPY_PHASE_STRIP = NO; 308 | DEBUG_INFORMATION_FORMAT = dwarf; 309 | ENABLE_STRICT_OBJC_MSGSEND = YES; 310 | ENABLE_TESTABILITY = YES; 311 | GCC_C_LANGUAGE_STANDARD = gnu99; 312 | GCC_DYNAMIC_NO_PIC = NO; 313 | GCC_NO_COMMON_BLOCKS = YES; 314 | GCC_OPTIMIZATION_LEVEL = 0; 315 | GCC_PREPROCESSOR_DEFINITIONS = ( 316 | "DEBUG=1", 317 | "$(inherited)", 318 | ); 319 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 320 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 321 | GCC_WARN_UNDECLARED_SELECTOR = YES; 322 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 323 | GCC_WARN_UNUSED_FUNCTION = YES; 324 | GCC_WARN_UNUSED_VARIABLE = YES; 325 | IPHONEOS_DEPLOYMENT_TARGET = 10.2; 326 | MTL_ENABLE_DEBUG_INFO = YES; 327 | ONLY_ACTIVE_ARCH = YES; 328 | SDKROOT = iphoneos; 329 | TARGETED_DEVICE_FAMILY = "1,2"; 330 | }; 331 | name = Debug; 332 | }; 333 | ECAE8CAF1EA65BB10066ED62 /* Release */ = { 334 | isa = XCBuildConfiguration; 335 | buildSettings = { 336 | ALWAYS_SEARCH_USER_PATHS = NO; 337 | CLANG_ANALYZER_NONNULL = YES; 338 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 339 | CLANG_CXX_LIBRARY = "libc++"; 340 | CLANG_ENABLE_MODULES = YES; 341 | CLANG_ENABLE_OBJC_ARC = YES; 342 | CLANG_WARN_BOOL_CONVERSION = YES; 343 | CLANG_WARN_CONSTANT_CONVERSION = YES; 344 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 345 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 346 | CLANG_WARN_EMPTY_BODY = YES; 347 | CLANG_WARN_ENUM_CONVERSION = YES; 348 | CLANG_WARN_INFINITE_RECURSION = YES; 349 | CLANG_WARN_INT_CONVERSION = YES; 350 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 351 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 352 | CLANG_WARN_UNREACHABLE_CODE = YES; 353 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 354 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 355 | COPY_PHASE_STRIP = NO; 356 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 357 | ENABLE_NS_ASSERTIONS = NO; 358 | ENABLE_STRICT_OBJC_MSGSEND = YES; 359 | GCC_C_LANGUAGE_STANDARD = gnu99; 360 | GCC_NO_COMMON_BLOCKS = YES; 361 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 362 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 363 | GCC_WARN_UNDECLARED_SELECTOR = YES; 364 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 365 | GCC_WARN_UNUSED_FUNCTION = YES; 366 | GCC_WARN_UNUSED_VARIABLE = YES; 367 | IPHONEOS_DEPLOYMENT_TARGET = 10.2; 368 | MTL_ENABLE_DEBUG_INFO = NO; 369 | SDKROOT = iphoneos; 370 | TARGETED_DEVICE_FAMILY = "1,2"; 371 | VALIDATE_PRODUCT = YES; 372 | }; 373 | name = Release; 374 | }; 375 | ECAE8CB11EA65BB10066ED62 /* Debug */ = { 376 | isa = XCBuildConfiguration; 377 | buildSettings = { 378 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 379 | INFOPLIST_FILE = HZBannerViewDemo/Info.plist; 380 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 381 | PRODUCT_BUNDLE_IDENTIFIER = "Null-Coder.HZBannerViewDemo"; 382 | PRODUCT_NAME = "$(TARGET_NAME)"; 383 | }; 384 | name = Debug; 385 | }; 386 | ECAE8CB21EA65BB10066ED62 /* Release */ = { 387 | isa = XCBuildConfiguration; 388 | buildSettings = { 389 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 390 | INFOPLIST_FILE = HZBannerViewDemo/Info.plist; 391 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 392 | PRODUCT_BUNDLE_IDENTIFIER = "Null-Coder.HZBannerViewDemo"; 393 | PRODUCT_NAME = "$(TARGET_NAME)"; 394 | }; 395 | name = Release; 396 | }; 397 | /* End XCBuildConfiguration section */ 398 | 399 | /* Begin XCConfigurationList section */ 400 | ECAE8C941EA65BB10066ED62 /* Build configuration list for PBXProject "HZBannerViewDemo" */ = { 401 | isa = XCConfigurationList; 402 | buildConfigurations = ( 403 | ECAE8CAE1EA65BB10066ED62 /* Debug */, 404 | ECAE8CAF1EA65BB10066ED62 /* Release */, 405 | ); 406 | defaultConfigurationIsVisible = 0; 407 | defaultConfigurationName = Release; 408 | }; 409 | ECAE8CB01EA65BB10066ED62 /* Build configuration list for PBXNativeTarget "HZBannerViewDemo" */ = { 410 | isa = XCConfigurationList; 411 | buildConfigurations = ( 412 | ECAE8CB11EA65BB10066ED62 /* Debug */, 413 | ECAE8CB21EA65BB10066ED62 /* Release */, 414 | ); 415 | defaultConfigurationIsVisible = 0; 416 | defaultConfigurationName = Release; 417 | }; 418 | /* End XCConfigurationList section */ 419 | }; 420 | rootObject = ECAE8C911EA65BB10066ED62 /* Project object */; 421 | } 422 | -------------------------------------------------------------------------------- /HZBannerViewDemo/HZBannerViewDemo.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /HZBannerViewDemo/HZBannerViewDemo/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HughTsang/HZBannerViewDemo/3df18f2c35bf352c915f93790c22273c64694c5d/HZBannerViewDemo/HZBannerViewDemo/.DS_Store -------------------------------------------------------------------------------- /HZBannerViewDemo/HZBannerViewDemo/AppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.h 3 | // HZBannerViewDemo 4 | // 5 | // Created by Null on 2017/4/18. 6 | // Copyright © 2017年 Null. 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 | -------------------------------------------------------------------------------- /HZBannerViewDemo/HZBannerViewDemo/AppDelegate.m: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.m 3 | // HZBannerViewDemo 4 | // 5 | // Created by Null on 2017/4/18. 6 | // Copyright © 2017年 Null. All rights reserved. 7 | // 8 | 9 | #import "AppDelegate.h" 10 | 11 | @interface AppDelegate () 12 | 13 | @end 14 | 15 | @implementation AppDelegate 16 | 17 | 18 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { 19 | // Override point for customization after application launch. 20 | return YES; 21 | } 22 | 23 | 24 | - (void)applicationWillResignActive:(UIApplication *)application { 25 | // 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. 26 | // Use this method to pause ongoing tasks, disable timers, and invalidate graphics rendering callbacks. Games should use this method to pause the game. 27 | } 28 | 29 | 30 | - (void)applicationDidEnterBackground:(UIApplication *)application { 31 | // 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. 32 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 33 | } 34 | 35 | 36 | - (void)applicationWillEnterForeground:(UIApplication *)application { 37 | // Called as part of the transition from the background to the active state; here you can undo many of the changes made on entering the background. 38 | } 39 | 40 | 41 | - (void)applicationDidBecomeActive:(UIApplication *)application { 42 | // 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. 43 | } 44 | 45 | 46 | - (void)applicationWillTerminate:(UIApplication *)application { 47 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 48 | } 49 | 50 | 51 | @end 52 | -------------------------------------------------------------------------------- /HZBannerViewDemo/HZBannerViewDemo/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "20x20", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "20x20", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "29x29", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "29x29", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "40x40", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "40x40", 31 | "scale" : "3x" 32 | }, 33 | { 34 | "idiom" : "iphone", 35 | "size" : "60x60", 36 | "scale" : "2x" 37 | }, 38 | { 39 | "idiom" : "iphone", 40 | "size" : "60x60", 41 | "scale" : "3x" 42 | }, 43 | { 44 | "idiom" : "ipad", 45 | "size" : "20x20", 46 | "scale" : "1x" 47 | }, 48 | { 49 | "idiom" : "ipad", 50 | "size" : "20x20", 51 | "scale" : "2x" 52 | }, 53 | { 54 | "idiom" : "ipad", 55 | "size" : "29x29", 56 | "scale" : "1x" 57 | }, 58 | { 59 | "idiom" : "ipad", 60 | "size" : "29x29", 61 | "scale" : "2x" 62 | }, 63 | { 64 | "idiom" : "ipad", 65 | "size" : "40x40", 66 | "scale" : "1x" 67 | }, 68 | { 69 | "idiom" : "ipad", 70 | "size" : "40x40", 71 | "scale" : "2x" 72 | }, 73 | { 74 | "idiom" : "ipad", 75 | "size" : "76x76", 76 | "scale" : "1x" 77 | }, 78 | { 79 | "idiom" : "ipad", 80 | "size" : "76x76", 81 | "scale" : "2x" 82 | }, 83 | { 84 | "idiom" : "ipad", 85 | "size" : "83.5x83.5", 86 | "scale" : "2x" 87 | } 88 | ], 89 | "info" : { 90 | "version" : 1, 91 | "author" : "xcode" 92 | } 93 | } -------------------------------------------------------------------------------- /HZBannerViewDemo/HZBannerViewDemo/Assets.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "version" : 1, 4 | "author" : "xcode" 5 | } 6 | } -------------------------------------------------------------------------------- /HZBannerViewDemo/HZBannerViewDemo/Assets.xcassets/defaultImage.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "scale" : "1x" 6 | }, 7 | { 8 | "idiom" : "universal", 9 | "filename" : "defaultImage@2x.jpg", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "scale" : "3x" 15 | } 16 | ], 17 | "info" : { 18 | "version" : 1, 19 | "author" : "xcode" 20 | } 21 | } -------------------------------------------------------------------------------- /HZBannerViewDemo/HZBannerViewDemo/Assets.xcassets/defaultImage.imageset/defaultImage@2x.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HughTsang/HZBannerViewDemo/3df18f2c35bf352c915f93790c22273c64694c5d/HZBannerViewDemo/HZBannerViewDemo/Assets.xcassets/defaultImage.imageset/defaultImage@2x.jpg -------------------------------------------------------------------------------- /HZBannerViewDemo/HZBannerViewDemo/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 | -------------------------------------------------------------------------------- /HZBannerViewDemo/HZBannerViewDemo/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 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | -------------------------------------------------------------------------------- /HZBannerViewDemo/HZBannerViewDemo/HZBannerView/HZBannerCell.h: -------------------------------------------------------------------------------- 1 | // 2 | // HZBannerCell.h 3 | // 4 | // Created by zenghz on 2017/4/18. 5 | // Copyright © 2017年 Personal. All rights reserved. 6 | // 7 | 8 | #import 9 | 10 | @class HZBannerModel; 11 | 12 | @interface HZBannerCell : UICollectionViewCell 13 | 14 | /** 数据模型 */ 15 | @property (nonatomic, strong) HZBannerModel *model; 16 | 17 | @end 18 | -------------------------------------------------------------------------------- /HZBannerViewDemo/HZBannerViewDemo/HZBannerView/HZBannerCell.m: -------------------------------------------------------------------------------- 1 | // 2 | // HZBannerCell.m 3 | // 4 | // Created by zenghz on 2017/4/18. 5 | // Copyright © 2017年 Personal. All rights reserved. 6 | // 7 | 8 | #import "HZBannerCell.h" 9 | #import "HZBannerModel.h" 10 | 11 | @interface HZBannerCell () 12 | { 13 | UIImageView *_imageView; 14 | UILabel *_textLabel; 15 | } 16 | @end 17 | 18 | @implementation HZBannerCell 19 | 20 | - (instancetype)initWithFrame:(CGRect)frame { 21 | 22 | if (self = [super initWithFrame:frame]) { 23 | 24 | self.layer.cornerRadius = 10.0f; 25 | self.layer.masksToBounds = YES; 26 | self.backgroundColor = [UIColor whiteColor]; 27 | 28 | [self setupUI]; 29 | } 30 | return self; 31 | } 32 | 33 | - (void)setupUI { 34 | 35 | CGFloat labelHeight = self.bounds.size.height * 0.20f; 36 | CGFloat imageViewHeight = self.bounds.size.height - labelHeight; 37 | _imageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, self.bounds.size.width, imageViewHeight)]; 38 | _imageView.contentMode = UIViewContentModeScaleAspectFill; 39 | _imageView.layer.masksToBounds = true; 40 | [self addSubview:_imageView]; 41 | 42 | _textLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, imageViewHeight, self.bounds.size.width, labelHeight)]; 43 | _textLabel.textColor = [UIColor colorWithRed:102.0f/255.0f green:102.0f/255.0f blue:102.0f/255.0f alpha:1]; 44 | _textLabel.font = [UIFont systemFontOfSize:22]; 45 | _textLabel.textAlignment = NSTextAlignmentCenter; 46 | _textLabel.adjustsFontSizeToFitWidth = true; 47 | [self addSubview:_textLabel]; 48 | 49 | 50 | } 51 | 52 | - (void)setModel:(HZBannerModel *)model{ 53 | 54 | _model = model; 55 | 56 | _imageView.image = [UIImage imageNamed:model.picture]; 57 | _textLabel.text = model.title; 58 | } 59 | 60 | 61 | @end 62 | -------------------------------------------------------------------------------- /HZBannerViewDemo/HZBannerViewDemo/HZBannerView/HZBannerModel.h: -------------------------------------------------------------------------------- 1 | // 2 | // HZBannerModel.h 3 | // 4 | // Created by zenghz on 2017/4/18. 5 | // Copyright © 2017年 Personal. All rights reserved. 6 | // 7 | 8 | #import 9 | 10 | @interface HZBannerModel : NSObject 11 | 12 | /** 图片 */ 13 | @property (nonatomic, copy) NSString *picture; 14 | /** 标题 */ 15 | @property (nonatomic, copy) NSString *title; 16 | 17 | @end 18 | -------------------------------------------------------------------------------- /HZBannerViewDemo/HZBannerViewDemo/HZBannerView/HZBannerModel.m: -------------------------------------------------------------------------------- 1 | // 2 | // HZBannerModel.m 3 | // 4 | // Created by zenghz on 2017/4/18. 5 | // Copyright © 2017年 Personal. All rights reserved. 6 | // 7 | 8 | #import "HZBannerModel.h" 9 | 10 | @implementation HZBannerModel 11 | 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /HZBannerViewDemo/HZBannerViewDemo/HZBannerView/HZBannerView.h: -------------------------------------------------------------------------------- 1 | // 2 | // HZBannerView.h 3 | // 4 | // Created by zenghz on 2017/4/18. 5 | // Copyright © 2017年 Personal. All rights reserved. 6 | // 7 | // [GitHub地址](https://github.com/Null-Coder/HZBannerViewDemo.git) 8 | 9 | #import 10 | #import "HZBannerModel.h" 11 | 12 | @class HZBannerView; 13 | 14 | @protocol HZBannerViewDelegate 15 | 16 | @optional 17 | /** 18 | 该方法用来处理item的点击,会返回item在moxing数组中的索引 19 | 20 | @param bannerView 控件本身 21 | @param index 索引 22 | */ 23 | - (void)HZBannerView:(HZBannerView *)bannerView didSelectedAt:(NSInteger)index; 24 | 25 | @end 26 | 27 | @interface HZBannerView : UIView 28 | 29 | #pragma mark - 属性 30 | /** 31 | * 模型数组 32 | */ 33 | @property (nonatomic, strong) NSArray *models; 34 | /** 35 | * 代理,用来处理图片的点击 36 | */ 37 | @property (nonatomic, weak) id delegate; 38 | /** 39 | * 每一页停留时间,默认为3s,最少1s 40 | * 当设置的值小于1s时,则为默认值 41 | */ 42 | @property (nonatomic, assign) NSTimeInterval timeInterval; 43 | 44 | #pragma mark - 方法 45 | /** 46 | * 开启定时器 47 | * 默认已开启,调用该方法会重新开启 48 | */ 49 | - (void)startTimer; 50 | /** 51 | * 停止定时器 52 | * 停止后,如果手动滚动图片,定时器会重新开启 53 | */ 54 | - (void)stopTimer; 55 | 56 | @end 57 | -------------------------------------------------------------------------------- /HZBannerViewDemo/HZBannerViewDemo/HZBannerView/HZBannerView.m: -------------------------------------------------------------------------------- 1 | // 2 | // HZBannerView.m 3 | // 4 | // Created by zenghz on 2017/4/18. 5 | // Copyright © 2017年 Personal. All rights reserved. 6 | // 7 | // [GitHub地址](https://github.com/Null-Coder/HZBannerViewDemo.git) 8 | 9 | #import "HZBannerView.h" 10 | #import "HZBannerViewFlowLayout.h" 11 | #import "HZBannerCell.h" 12 | #import "HZBannerModel.h" 13 | 14 | //居中卡片宽度与据屏幕宽度比例 15 | static CGFloat const CardWidthScale = 0.7f; 16 | static CGFloat const CardHeightScale = 0.9f; 17 | //默认定时器时间 18 | static CGFloat const DefaultTime = 3.0f; 19 | 20 | static NSString * const reusedID = @"HZBannerCellID"; 21 | 22 | @interface HZBannerView () 23 | { 24 | NSInteger _currentIndex; 25 | CGFloat _dragStartX; 26 | CGFloat _dragEndX; 27 | } 28 | @property (nonatomic, strong) UICollectionView *collection; 29 | @property (nonatomic, strong) UIImageView *imageView;//虚化背景 30 | @property (nonatomic, strong) NSTimer *timer;//定时器 31 | 32 | @end 33 | 34 | @implementation HZBannerView 35 | 36 | #pragma mark - 懒加载 37 | - (UIImageView *)imageView{ 38 | 39 | return _imageView = _imageView ?: ({ 40 | UIImageView *imageView = [[UIImageView alloc] initWithFrame:self.bounds]; 41 | [self addSubview:imageView]; 42 | 43 | UIBlurEffect* effect = [UIBlurEffect effectWithStyle:UIBlurEffectStyleLight]; 44 | UIVisualEffectView* effectView = [[UIVisualEffectView alloc] initWithEffect:effect]; 45 | effectView.frame = imageView.bounds; 46 | [imageView addSubview:effectView]; 47 | imageView; 48 | }); 49 | } 50 | 51 | - (HZBannerViewFlowLayout *)flowLayout{ 52 | 53 | HZBannerViewFlowLayout *flowLayout = [[HZBannerViewFlowLayout alloc] init]; 54 | [flowLayout setItemSize:CGSizeMake([self cellWidth],self.bounds.size.height * CardHeightScale)]; 55 | [flowLayout setScrollDirection:UICollectionViewScrollDirectionHorizontal]; 56 | [flowLayout setMinimumLineSpacing:[self cellMargin]]; 57 | return flowLayout; 58 | } 59 | 60 | - (UICollectionView *)collection{ 61 | 62 | return _collection = _collection ?: ({ 63 | UICollectionView *collectionView = [[UICollectionView alloc] initWithFrame:self.bounds collectionViewLayout:[self flowLayout]]; 64 | collectionView.showsHorizontalScrollIndicator = false; 65 | collectionView.backgroundColor = [UIColor clearColor]; 66 | [collectionView registerClass:[HZBannerCell class] forCellWithReuseIdentifier:reusedID]; 67 | [collectionView setUserInteractionEnabled:YES]; 68 | collectionView.delegate = self; 69 | collectionView.dataSource = self; 70 | [self addSubview:collectionView]; 71 | collectionView; 72 | }); 73 | } 74 | 75 | #pragma mark - 构造方法 76 | - (instancetype)initWithFrame:(CGRect)frame { 77 | 78 | if (self = [super initWithFrame:frame]) { 79 | 80 | } 81 | return self; 82 | } 83 | 84 | #pragma mark Setter 85 | - (void)setModels:(NSArray *)models{ 86 | 87 | if (models.count == 0) { 88 | return; 89 | } 90 | //处理模型 实现无限滚动 91 | NSMutableArray *modelsM = @[].mutableCopy; 92 | [modelsM addObjectsFromArray:models]; 93 | 94 | if (modelsM.count >= 3) { 95 | 96 | HZBannerModel *first = modelsM.firstObject; 97 | HZBannerModel *seconed = modelsM[1]; 98 | HZBannerModel *last = modelsM.lastObject; 99 | HZBannerModel *lastTwo = modelsM[models.count - 2]; 100 | 101 | [modelsM insertObject:last atIndex:0]; 102 | [modelsM insertObject:lastTwo atIndex:0]; 103 | 104 | [modelsM addObject:first]; 105 | [modelsM addObject:seconed]; 106 | }else if (modelsM.count == 2) { 107 | 108 | HZBannerModel *first = modelsM.firstObject; 109 | HZBannerModel *seconed = modelsM.lastObject; 110 | HZBannerModel *last = modelsM.lastObject; 111 | HZBannerModel *lastTwo = modelsM.firstObject; 112 | 113 | [modelsM insertObject:last atIndex:0]; 114 | [modelsM insertObject:lastTwo atIndex:0]; 115 | 116 | [modelsM addObject:first]; 117 | [modelsM addObject:seconed]; 118 | }else if (modelsM.count == 1) { 119 | 120 | HZBannerModel *first = modelsM.firstObject; 121 | HZBannerModel *seconed = modelsM.firstObject; 122 | HZBannerModel *last = modelsM.lastObject; 123 | HZBannerModel *lastTwo = models.lastObject; 124 | 125 | [modelsM insertObject:last atIndex:0]; 126 | [modelsM insertObject:lastTwo atIndex:0]; 127 | 128 | [modelsM addObject:first]; 129 | [modelsM addObject:seconed]; 130 | } 131 | 132 | _models = modelsM; 133 | 134 | //设置初始位置 135 | if (models.count > 0) { 136 | 137 | HZBannerModel *model = _models.firstObject; 138 | self.imageView.image = [UIImage imageNamed:model.picture]; 139 | _currentIndex = 2; 140 | [self.collection scrollToItemAtIndexPath:[NSIndexPath indexPathForRow:_currentIndex inSection:0] atScrollPosition:UICollectionViewScrollPositionCenteredHorizontally animated:NO]; 141 | //开启定时器 142 | [self startTimer]; 143 | } 144 | } 145 | 146 | #pragma mark - CollectionDelegate 147 | //配置cell居中 148 | - (void)fixCellToCenter { 149 | 150 | //最小滚动距离 151 | float dragMiniDistance = self.bounds.size.width/20.0f; 152 | if (_dragStartX - _dragEndX >= dragMiniDistance) { 153 | _currentIndex -= 1;//向右 154 | }else if(_dragEndX - _dragStartX >= dragMiniDistance){ 155 | _currentIndex += 1;//向左 156 | } 157 | NSInteger maxIndex = [self.collection numberOfItemsInSection:0] - 1; 158 | _currentIndex = _currentIndex <= 0 ? 0 : _currentIndex; 159 | _currentIndex = _currentIndex >= maxIndex ? maxIndex : _currentIndex; 160 | 161 | [self scrollToCenter]; 162 | } 163 | 164 | - (void)scrollToCenter { 165 | 166 | [self.collection scrollToItemAtIndexPath:[NSIndexPath indexPathForRow:_currentIndex inSection:0] atScrollPosition:UICollectionViewScrollPositionCenteredHorizontally animated:YES]; 167 | 168 | HZBannerModel *model = _models[_currentIndex]; 169 | self.imageView.image = [UIImage imageNamed:model.picture]; 170 | 171 | //如果是最后一张图 172 | if (_currentIndex == self.models.count - 1 ) { 173 | 174 | _currentIndex = 2; 175 | [self.collection scrollToItemAtIndexPath:[NSIndexPath indexPathForRow:_currentIndex inSection:0] atScrollPosition:UICollectionViewScrollPositionCenteredHorizontally animated:NO]; 176 | 177 | HZBannerModel *model = _models[_currentIndex]; 178 | self.imageView.image = [UIImage imageNamed:model.picture]; 179 | return; 180 | } 181 | //第一张图 182 | else if (_currentIndex == 1) { 183 | 184 | _currentIndex = self.models.count - 3; 185 | [self.collection scrollToItemAtIndexPath:[NSIndexPath indexPathForRow:_currentIndex inSection:0] atScrollPosition:UICollectionViewScrollPositionCenteredHorizontally animated:NO]; 186 | 187 | HZBannerModel *model = _models[_currentIndex]; 188 | self.imageView.image = [UIImage imageNamed:model.picture]; 189 | return; 190 | } 191 | } 192 | 193 | #pragma mark - CollectionDataSource 194 | 195 | //卡片宽度 196 | - (CGFloat)cellWidth { 197 | return self.bounds.size.width * CardWidthScale; 198 | } 199 | 200 | //卡片间隔 201 | - (CGFloat)cellMargin { 202 | return (self.bounds.size.width - [self cellWidth])/4; 203 | } 204 | 205 | //设置左右缩进 206 | - (CGFloat)collectionInset { 207 | 208 | return self.bounds.size.width/2.0f - [self cellWidth]/2.0f; 209 | } 210 | 211 | - (UIEdgeInsets)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout insetForSectionAtIndex:(NSInteger)section { 212 | 213 | return UIEdgeInsetsMake(0, [self collectionInset], 0, [self collectionInset]); 214 | } 215 | 216 | - (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section { 217 | 218 | return _models.count; 219 | } 220 | 221 | - (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath { 222 | 223 | HZBannerCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:reusedID forIndexPath:indexPath]; 224 | cell.model = _models[indexPath.row]; 225 | return cell; 226 | } 227 | 228 | #pragma mark- --------定时器相关方法-------- 229 | #pragma mark 设置定时器时间 230 | - (void)setTimeInterval:(NSTimeInterval)timeInterval { 231 | _timeInterval = timeInterval; 232 | [self startTimer]; 233 | } 234 | 235 | - (void)startTimer { 236 | //如果只有一张图片,则直接返回,不开启定时器 237 | if (_models.count <= 1) return; 238 | //如果定时器已开启,先停止再重新开启 239 | if (self.timer){ 240 | [self stopTimer]; 241 | } 242 | NSTimeInterval timeInterval = _timeInterval ? (_timeInterval >= 1 ?: 1) : DefaultTime; 243 | self.timer = [NSTimer timerWithTimeInterval:timeInterval target:self selector:@selector(nextPage) userInfo:nil repeats:YES]; 244 | [[NSRunLoop currentRunLoop] addTimer:self.timer forMode:NSRunLoopCommonModes]; 245 | } 246 | 247 | - (void)stopTimer { 248 | [self.timer invalidate]; 249 | self.timer = nil; 250 | } 251 | 252 | - (void)nextPage { 253 | 254 | _currentIndex += 1; 255 | 256 | [self scrollToCenter]; 257 | } 258 | 259 | #pragma mark - UIScrollViewDelegate 260 | //手指拖动开始 261 | - (void)scrollViewWillBeginDragging:(UIScrollView *)scrollView { 262 | 263 | _dragStartX = scrollView.contentOffset.x; 264 | [self stopTimer]; 265 | } 266 | 267 | //手指拖动停止 268 | - (void)scrollViewDidEndDragging:(UIScrollView *)scrollView willDecelerate:(BOOL)decelerate { 269 | 270 | _dragEndX = scrollView.contentOffset.x; 271 | dispatch_async(dispatch_get_main_queue(), ^{ 272 | [self fixCellToCenter]; 273 | }); 274 | 275 | [self startTimer]; 276 | } 277 | 278 | - (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath { 279 | 280 | _currentIndex = indexPath.row; 281 | [self scrollToCenter]; 282 | 283 | if (self.delegate && 284 | [self.delegate respondsToSelector:@selector(HZBannerView:didSelectedAt:)]) { 285 | [self.delegate HZBannerView:self didSelectedAt:indexPath.row]; 286 | } 287 | } 288 | 289 | 290 | 291 | 292 | @end 293 | -------------------------------------------------------------------------------- /HZBannerViewDemo/HZBannerViewDemo/HZBannerView/HZBannerViewFlowLayout.h: -------------------------------------------------------------------------------- 1 | // 2 | // HZBannerViewFlowLayout.h 3 | // 4 | // Created by zenghz on 2017/4/18. 5 | // Copyright © 2017年 Personal. All rights reserved. 6 | // 7 | // [GitHub地址](https://github.com/Null-Coder/HZBannerViewDemo.git) 8 | 9 | #import 10 | 11 | @interface HZBannerViewFlowLayout : UICollectionViewFlowLayout 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /HZBannerViewDemo/HZBannerViewDemo/HZBannerView/HZBannerViewFlowLayout.m: -------------------------------------------------------------------------------- 1 | // 2 | // HZBannerViewFlowLayout.m 3 | // 4 | // Created by zenghz on 2017/4/18. 5 | // Copyright © 2017年 Personal. All rights reserved. 6 | // 7 | // [GitHub地址](https://github.com/Null-Coder/HZBannerViewDemo.git) 8 | 9 | #import "HZBannerViewFlowLayout.h" 10 | 11 | @implementation HZBannerViewFlowLayout 12 | 13 | //设置放大动画 14 | - (NSArray *)layoutAttributesForElementsInRect:(CGRect)rect { 15 | 16 | NSArray *arr = [self getCopyOfAttributes:[super layoutAttributesForElementsInRect:rect]]; 17 | //屏幕中线 18 | CGFloat centerX = self.collectionView.contentOffset.x + self.collectionView.bounds.size.width/2.0f; 19 | //刷新cell缩放 20 | for (UICollectionViewLayoutAttributes *attributes in arr) { 21 | CGFloat distance = fabs(attributes.center.x - centerX); 22 | //移动的距离和屏幕宽度的的比例 23 | CGFloat apartScale = distance/self.collectionView.bounds.size.width; 24 | //把卡片移动范围固定到 -π/4到 +π/4这一个范围内 25 | CGFloat scale = fabs(cos(apartScale * M_PI/4)); 26 | //设置cell的缩放 按照余弦函数曲线 越居中越趋近于1 27 | attributes.transform = CGAffineTransformMakeScale(1.0, scale); 28 | } 29 | return arr; 30 | } 31 | 32 | - (BOOL)shouldInvalidateLayoutForBoundsChange:(CGRect)newBounds { 33 | 34 | return true; 35 | } 36 | 37 | //防止报错 先复制attributes 38 | - (NSArray *)getCopyOfAttributes:(NSArray *)attributes { 39 | 40 | NSMutableArray *copyArr = [NSMutableArray new]; 41 | for (UICollectionViewLayoutAttributes *attribute in attributes) { 42 | [copyArr addObject:[attribute copy]]; 43 | } 44 | return copyArr; 45 | } 46 | 47 | @end 48 | -------------------------------------------------------------------------------- /HZBannerViewDemo/HZBannerViewDemo/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleDisplayName 8 | 轮播图 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 | 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 | UISupportedInterfaceOrientations~ipad 40 | 41 | UIInterfaceOrientationPortrait 42 | UIInterfaceOrientationPortraitUpsideDown 43 | UIInterfaceOrientationLandscapeLeft 44 | UIInterfaceOrientationLandscapeRight 45 | 46 | 47 | 48 | -------------------------------------------------------------------------------- /HZBannerViewDemo/HZBannerViewDemo/Resources/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HughTsang/HZBannerViewDemo/3df18f2c35bf352c915f93790c22273c64694c5d/HZBannerViewDemo/HZBannerViewDemo/Resources/.DS_Store -------------------------------------------------------------------------------- /HZBannerViewDemo/HZBannerViewDemo/Resources/DataPropertyList.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | title 7 | 艾德·史塔克 8 | picture 9 | 1.png 10 | 11 | 12 | title 13 | 凯瑟琳·徒利·史塔克 14 | picture 15 | 2.png 16 | 17 | 18 | title 19 | 罗柏·史塔克 20 | picture 21 | 3.png 22 | 23 | 24 | title 25 | 琼恩·雪诺 26 | picture 27 | 4.png 28 | 29 | 30 | title 31 | 艾莉亚·史塔克 32 | picture 33 | 5.png 34 | 35 | 36 | title 37 | 珊莎·史塔克 38 | picture 39 | 6.png 40 | 41 | 42 | title 43 | 布兰·史塔克 44 | picture 45 | 7.png 46 | 47 | 48 | title 49 | 瑟曦·兰尼斯特·拜拉席恩 50 | picture 51 | 8.png 52 | 53 | 54 | title 55 | 提利昂·兰尼斯特 56 | picture 57 | 9.png 58 | 59 | 60 | title 61 | 泰温·兰尼斯特 62 | picture 63 | 10.png 64 | 65 | 66 | title 67 | 詹姆·兰尼斯特 68 | picture 69 | 11.png 70 | 71 | 72 | title 73 | 乔佛里·拜拉席恩 74 | picture 75 | 12.png 76 | 77 | 78 | title 79 | 丹尼莉丝·坦格利安 80 | picture 81 | 13.png 82 | 83 | 84 | 85 | -------------------------------------------------------------------------------- /HZBannerViewDemo/HZBannerViewDemo/Resources/Images/1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HughTsang/HZBannerViewDemo/3df18f2c35bf352c915f93790c22273c64694c5d/HZBannerViewDemo/HZBannerViewDemo/Resources/Images/1.png -------------------------------------------------------------------------------- /HZBannerViewDemo/HZBannerViewDemo/Resources/Images/10.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HughTsang/HZBannerViewDemo/3df18f2c35bf352c915f93790c22273c64694c5d/HZBannerViewDemo/HZBannerViewDemo/Resources/Images/10.png -------------------------------------------------------------------------------- /HZBannerViewDemo/HZBannerViewDemo/Resources/Images/11.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HughTsang/HZBannerViewDemo/3df18f2c35bf352c915f93790c22273c64694c5d/HZBannerViewDemo/HZBannerViewDemo/Resources/Images/11.png -------------------------------------------------------------------------------- /HZBannerViewDemo/HZBannerViewDemo/Resources/Images/12.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HughTsang/HZBannerViewDemo/3df18f2c35bf352c915f93790c22273c64694c5d/HZBannerViewDemo/HZBannerViewDemo/Resources/Images/12.png -------------------------------------------------------------------------------- /HZBannerViewDemo/HZBannerViewDemo/Resources/Images/13.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HughTsang/HZBannerViewDemo/3df18f2c35bf352c915f93790c22273c64694c5d/HZBannerViewDemo/HZBannerViewDemo/Resources/Images/13.png -------------------------------------------------------------------------------- /HZBannerViewDemo/HZBannerViewDemo/Resources/Images/2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HughTsang/HZBannerViewDemo/3df18f2c35bf352c915f93790c22273c64694c5d/HZBannerViewDemo/HZBannerViewDemo/Resources/Images/2.png -------------------------------------------------------------------------------- /HZBannerViewDemo/HZBannerViewDemo/Resources/Images/3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HughTsang/HZBannerViewDemo/3df18f2c35bf352c915f93790c22273c64694c5d/HZBannerViewDemo/HZBannerViewDemo/Resources/Images/3.png -------------------------------------------------------------------------------- /HZBannerViewDemo/HZBannerViewDemo/Resources/Images/4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HughTsang/HZBannerViewDemo/3df18f2c35bf352c915f93790c22273c64694c5d/HZBannerViewDemo/HZBannerViewDemo/Resources/Images/4.png -------------------------------------------------------------------------------- /HZBannerViewDemo/HZBannerViewDemo/Resources/Images/5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HughTsang/HZBannerViewDemo/3df18f2c35bf352c915f93790c22273c64694c5d/HZBannerViewDemo/HZBannerViewDemo/Resources/Images/5.png -------------------------------------------------------------------------------- /HZBannerViewDemo/HZBannerViewDemo/Resources/Images/6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HughTsang/HZBannerViewDemo/3df18f2c35bf352c915f93790c22273c64694c5d/HZBannerViewDemo/HZBannerViewDemo/Resources/Images/6.png -------------------------------------------------------------------------------- /HZBannerViewDemo/HZBannerViewDemo/Resources/Images/7.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HughTsang/HZBannerViewDemo/3df18f2c35bf352c915f93790c22273c64694c5d/HZBannerViewDemo/HZBannerViewDemo/Resources/Images/7.png -------------------------------------------------------------------------------- /HZBannerViewDemo/HZBannerViewDemo/Resources/Images/8.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HughTsang/HZBannerViewDemo/3df18f2c35bf352c915f93790c22273c64694c5d/HZBannerViewDemo/HZBannerViewDemo/Resources/Images/8.png -------------------------------------------------------------------------------- /HZBannerViewDemo/HZBannerViewDemo/Resources/Images/9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HughTsang/HZBannerViewDemo/3df18f2c35bf352c915f93790c22273c64694c5d/HZBannerViewDemo/HZBannerViewDemo/Resources/Images/9.png -------------------------------------------------------------------------------- /HZBannerViewDemo/HZBannerViewDemo/ViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.h 3 | // HZBannerViewDemo 4 | // 5 | // Created by Null on 2017/4/18. 6 | // Copyright © 2017年 Null. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface ViewController : UIViewController 12 | 13 | 14 | @end 15 | 16 | -------------------------------------------------------------------------------- /HZBannerViewDemo/HZBannerViewDemo/ViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.m 3 | // HZBannerViewDemo 4 | // 5 | // Created by Null on 2017/4/18. 6 | // Copyright © 2017年 Null. All rights reserved. 7 | // 8 | 9 | #import "ViewController.h" 10 | #import "HZBannerView.h" 11 | 12 | @interface ViewController () 13 | 14 | @end 15 | 16 | @implementation ViewController 17 | 18 | - (void)viewDidLoad { 19 | [super viewDidLoad]; 20 | 21 | NSString *filePath = [[NSBundle mainBundle] pathForResource:@"DataPropertyList" ofType:@"plist"]; 22 | NSArray *arr = [NSArray arrayWithContentsOfFile:filePath]; 23 | NSMutableArray *models = @[].mutableCopy; 24 | for (NSDictionary *dic in arr) { 25 | HZBannerModel *model = [HZBannerModel new]; 26 | [model setValuesForKeysWithDictionary:dic]; 27 | [models addObject:model]; 28 | } 29 | 30 | HZBannerView *banner = ({ 31 | 32 | CGFloat width = self.view.bounds.size.width; 33 | HZBannerView *banner = [[HZBannerView alloc] initWithFrame:CGRectMake(0, 64, width, width)]; 34 | banner.models = models; 35 | banner.delegate = self; 36 | banner; 37 | }); 38 | [self.view addSubview:banner]; 39 | 40 | } 41 | 42 | #pragma mark ----HZBannerViewDelegate---- 43 | - (void)HZBannerView:(HZBannerView *)bannerView didSelectedAt:(NSInteger)index{ 44 | 45 | NSLog(@"你选择了\"%@\"", bannerView.models[index].title); 46 | } 47 | 48 | @end 49 | -------------------------------------------------------------------------------- /HZBannerViewDemo/HZBannerViewDemo/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // HZBannerViewDemo 4 | // 5 | // Created by Null on 2017/4/18. 6 | // Copyright © 2017年 Null. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "AppDelegate.h" 11 | 12 | int main(int argc, char * argv[]) { 13 | @autoreleasepool { 14 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # HZBannerViewDemo 2 | ## 轮播图 3 | 4 | ![示例图片](http://upload-images.jianshu.io/upload_images/2764759-f64546efd505f504.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240) 5 | # 使用方法 6 | 0.导入文件夹`HZBannerView` 7 | 8 | 1.导入类 9 | `#import "HZBannerView.h"` 10 | 11 | 2.使用代码示例 12 | ``` 13 | GFloat width = self.view.bounds.size.width; 14 | HZBannerView *banner = [[HZBannerView alloc] initWithFrame:CGRectMake(0, 64, width, width)]; 15 | banner.models = models; 16 | [self.view addSubview:banner]; 17 | ``` 18 | >注意:这里的models为`NSArray *`类型,使用时候自己转换下模型即可,示例可见GitHubDemo 19 | 20 | 3.如需监听轮播图点击,只需设置代理 21 | `banner.delegate = self;` 22 | 遵守``协议 23 | 24 | 实现`-(void)HZBannerView:(HZBannerView *)bannerView didSelectedAt:(NSInteger)index;`方法即可 25 | --------------------------------------------------------------------------------