├── .gitignore ├── AYPageControl.podspec ├── AYPageControl.xcodeproj ├── project.pbxproj └── project.xcworkspace │ └── contents.xcworkspacedata ├── AYPageControl ├── AYPageControl │ ├── AYCircleLayer.h │ ├── AYCircleLayer.m │ ├── AYLineLayer.h │ ├── AYLineLayer.m │ ├── AYPageControl.h │ ├── AYPageControlView.h │ └── AYPageControlView.m ├── AppDelegate.h ├── AppDelegate.m ├── Assets.xcassets │ ├── AppIcon.appiconset │ │ └── Contents.json │ ├── Contents.json │ └── blog.imageset │ │ ├── Contents.json │ │ └── blog.png ├── Base.lproj │ ├── LaunchScreen.storyboard │ └── Main.storyboard ├── Info.plist ├── ViewController.h ├── ViewController.m └── main.m ├── AYPageControlTests ├── AYPageControlTests.m └── Info.plist ├── AYPageControlUITests ├── AYPageControlUITests.m └── Info.plist ├── License └── README.md /.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 | *.xccheckout 22 | *.moved-aside 23 | *.xcuserstate 24 | *.xcscmblueprint 25 | 26 | ## Obj-C/Swift specific 27 | *.hmap 28 | *.ipa 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/docs/Gitignore.md 51 | 52 | fastlane/report.xml 53 | fastlane/screenshots 54 | -------------------------------------------------------------------------------- /AYPageControl.podspec: -------------------------------------------------------------------------------- 1 | Pod::Spec.new do |s| 2 | 3 | s.name = "AYPageControl" 4 | s.version = "0.0.2" 5 | s.summary = "A PageControl With Drop Animation" 6 | s.homepage = "https://github.com/AYJk/AYPageControl.git" 7 | s.license = { :type => "MIT", :file => "LICENSE" } 8 | s.author = { "Andy" => "andy5759520@gmail.com" } 9 | s.platform = :ios, "7.0" 10 | s.source = { :git => "https://github.com/AYJk/AYPageControl.git", :tag => s.version } 11 | s.source_files = "AYPageControl/AYPageControl/*.{h,m}" 12 | s.requires_arc = true 13 | 14 | end -------------------------------------------------------------------------------- /AYPageControl.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | A14F6E341CA8DC26006D8F51 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = A14F6E331CA8DC26006D8F51 /* main.m */; }; 11 | A14F6E371CA8DC26006D8F51 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = A14F6E361CA8DC26006D8F51 /* AppDelegate.m */; }; 12 | A14F6E3A1CA8DC26006D8F51 /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = A14F6E391CA8DC26006D8F51 /* ViewController.m */; }; 13 | A14F6E3D1CA8DC26006D8F51 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = A14F6E3B1CA8DC26006D8F51 /* Main.storyboard */; }; 14 | A14F6E3F1CA8DC26006D8F51 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = A14F6E3E1CA8DC26006D8F51 /* Assets.xcassets */; }; 15 | A14F6E421CA8DC26006D8F51 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = A14F6E401CA8DC26006D8F51 /* LaunchScreen.storyboard */; }; 16 | A14F6E4D1CA8DC27006D8F51 /* AYPageControlTests.m in Sources */ = {isa = PBXBuildFile; fileRef = A14F6E4C1CA8DC27006D8F51 /* AYPageControlTests.m */; }; 17 | A14F6E581CA8DC27006D8F51 /* AYPageControlUITests.m in Sources */ = {isa = PBXBuildFile; fileRef = A14F6E571CA8DC27006D8F51 /* AYPageControlUITests.m */; }; 18 | A14F6E6A1CA8DC45006D8F51 /* AYCircleLayer.m in Sources */ = {isa = PBXBuildFile; fileRef = A14F6E671CA8DC45006D8F51 /* AYCircleLayer.m */; }; 19 | A14F6E721CA902A0006D8F51 /* AYPageControlView.m in Sources */ = {isa = PBXBuildFile; fileRef = A14F6E711CA902A0006D8F51 /* AYPageControlView.m */; }; 20 | A14F6E751CA902C4006D8F51 /* AYLineLayer.m in Sources */ = {isa = PBXBuildFile; fileRef = A14F6E741CA902C4006D8F51 /* AYLineLayer.m */; }; 21 | /* End PBXBuildFile section */ 22 | 23 | /* Begin PBXContainerItemProxy section */ 24 | A14F6E491CA8DC26006D8F51 /* PBXContainerItemProxy */ = { 25 | isa = PBXContainerItemProxy; 26 | containerPortal = A14F6E271CA8DC26006D8F51 /* Project object */; 27 | proxyType = 1; 28 | remoteGlobalIDString = A14F6E2E1CA8DC26006D8F51; 29 | remoteInfo = AYPageControl; 30 | }; 31 | A14F6E541CA8DC27006D8F51 /* PBXContainerItemProxy */ = { 32 | isa = PBXContainerItemProxy; 33 | containerPortal = A14F6E271CA8DC26006D8F51 /* Project object */; 34 | proxyType = 1; 35 | remoteGlobalIDString = A14F6E2E1CA8DC26006D8F51; 36 | remoteInfo = AYPageControl; 37 | }; 38 | /* End PBXContainerItemProxy section */ 39 | 40 | /* Begin PBXFileReference section */ 41 | A14F6E2F1CA8DC26006D8F51 /* AYPageControl.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = AYPageControl.app; sourceTree = BUILT_PRODUCTS_DIR; }; 42 | A14F6E331CA8DC26006D8F51 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; 43 | A14F6E351CA8DC26006D8F51 /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; 44 | A14F6E361CA8DC26006D8F51 /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; }; 45 | A14F6E381CA8DC26006D8F51 /* ViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ViewController.h; sourceTree = ""; }; 46 | A14F6E391CA8DC26006D8F51 /* ViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ViewController.m; sourceTree = ""; }; 47 | A14F6E3C1CA8DC26006D8F51 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 48 | A14F6E3E1CA8DC26006D8F51 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 49 | A14F6E411CA8DC26006D8F51 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 50 | A14F6E431CA8DC26006D8F51 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 51 | A14F6E481CA8DC26006D8F51 /* AYPageControlTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = AYPageControlTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 52 | A14F6E4C1CA8DC27006D8F51 /* AYPageControlTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AYPageControlTests.m; sourceTree = ""; }; 53 | A14F6E4E1CA8DC27006D8F51 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 54 | A14F6E531CA8DC27006D8F51 /* AYPageControlUITests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = AYPageControlUITests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 55 | A14F6E571CA8DC27006D8F51 /* AYPageControlUITests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AYPageControlUITests.m; sourceTree = ""; }; 56 | A14F6E591CA8DC27006D8F51 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 57 | A14F6E661CA8DC45006D8F51 /* AYCircleLayer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AYCircleLayer.h; sourceTree = ""; }; 58 | A14F6E671CA8DC45006D8F51 /* AYCircleLayer.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AYCircleLayer.m; sourceTree = ""; }; 59 | A14F6E6F1CA8FEC5006D8F51 /* AYPageControl.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AYPageControl.h; sourceTree = ""; }; 60 | A14F6E701CA902A0006D8F51 /* AYPageControlView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AYPageControlView.h; sourceTree = ""; }; 61 | A14F6E711CA902A0006D8F51 /* AYPageControlView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AYPageControlView.m; sourceTree = ""; }; 62 | A14F6E731CA902C4006D8F51 /* AYLineLayer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AYLineLayer.h; sourceTree = ""; }; 63 | A14F6E741CA902C4006D8F51 /* AYLineLayer.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AYLineLayer.m; sourceTree = ""; }; 64 | /* End PBXFileReference section */ 65 | 66 | /* Begin PBXFrameworksBuildPhase section */ 67 | A14F6E2C1CA8DC26006D8F51 /* Frameworks */ = { 68 | isa = PBXFrameworksBuildPhase; 69 | buildActionMask = 2147483647; 70 | files = ( 71 | ); 72 | runOnlyForDeploymentPostprocessing = 0; 73 | }; 74 | A14F6E451CA8DC26006D8F51 /* Frameworks */ = { 75 | isa = PBXFrameworksBuildPhase; 76 | buildActionMask = 2147483647; 77 | files = ( 78 | ); 79 | runOnlyForDeploymentPostprocessing = 0; 80 | }; 81 | A14F6E501CA8DC27006D8F51 /* Frameworks */ = { 82 | isa = PBXFrameworksBuildPhase; 83 | buildActionMask = 2147483647; 84 | files = ( 85 | ); 86 | runOnlyForDeploymentPostprocessing = 0; 87 | }; 88 | /* End PBXFrameworksBuildPhase section */ 89 | 90 | /* Begin PBXGroup section */ 91 | 116EBCBEBE509F9A8974457E /* Frameworks */ = { 92 | isa = PBXGroup; 93 | children = ( 94 | ); 95 | name = Frameworks; 96 | sourceTree = ""; 97 | }; 98 | A14F6E261CA8DC26006D8F51 = { 99 | isa = PBXGroup; 100 | children = ( 101 | A14F6E311CA8DC26006D8F51 /* AYPageControl */, 102 | A14F6E4B1CA8DC26006D8F51 /* AYPageControlTests */, 103 | A14F6E561CA8DC27006D8F51 /* AYPageControlUITests */, 104 | A14F6E301CA8DC26006D8F51 /* Products */, 105 | 116EBCBEBE509F9A8974457E /* Frameworks */, 106 | ); 107 | sourceTree = ""; 108 | }; 109 | A14F6E301CA8DC26006D8F51 /* Products */ = { 110 | isa = PBXGroup; 111 | children = ( 112 | A14F6E2F1CA8DC26006D8F51 /* AYPageControl.app */, 113 | A14F6E481CA8DC26006D8F51 /* AYPageControlTests.xctest */, 114 | A14F6E531CA8DC27006D8F51 /* AYPageControlUITests.xctest */, 115 | ); 116 | name = Products; 117 | sourceTree = ""; 118 | }; 119 | A14F6E311CA8DC26006D8F51 /* AYPageControl */ = { 120 | isa = PBXGroup; 121 | children = ( 122 | A14F6E651CA8DC45006D8F51 /* AYPageControl */, 123 | A14F6E351CA8DC26006D8F51 /* AppDelegate.h */, 124 | A14F6E361CA8DC26006D8F51 /* AppDelegate.m */, 125 | A14F6E381CA8DC26006D8F51 /* ViewController.h */, 126 | A14F6E391CA8DC26006D8F51 /* ViewController.m */, 127 | A14F6E3B1CA8DC26006D8F51 /* Main.storyboard */, 128 | A14F6E3E1CA8DC26006D8F51 /* Assets.xcassets */, 129 | A14F6E401CA8DC26006D8F51 /* LaunchScreen.storyboard */, 130 | A14F6E431CA8DC26006D8F51 /* Info.plist */, 131 | A14F6E321CA8DC26006D8F51 /* Supporting Files */, 132 | ); 133 | path = AYPageControl; 134 | sourceTree = ""; 135 | }; 136 | A14F6E321CA8DC26006D8F51 /* Supporting Files */ = { 137 | isa = PBXGroup; 138 | children = ( 139 | A14F6E331CA8DC26006D8F51 /* main.m */, 140 | ); 141 | name = "Supporting Files"; 142 | sourceTree = ""; 143 | }; 144 | A14F6E4B1CA8DC26006D8F51 /* AYPageControlTests */ = { 145 | isa = PBXGroup; 146 | children = ( 147 | A14F6E4C1CA8DC27006D8F51 /* AYPageControlTests.m */, 148 | A14F6E4E1CA8DC27006D8F51 /* Info.plist */, 149 | ); 150 | path = AYPageControlTests; 151 | sourceTree = ""; 152 | }; 153 | A14F6E561CA8DC27006D8F51 /* AYPageControlUITests */ = { 154 | isa = PBXGroup; 155 | children = ( 156 | A14F6E571CA8DC27006D8F51 /* AYPageControlUITests.m */, 157 | A14F6E591CA8DC27006D8F51 /* Info.plist */, 158 | ); 159 | path = AYPageControlUITests; 160 | sourceTree = ""; 161 | }; 162 | A14F6E651CA8DC45006D8F51 /* AYPageControl */ = { 163 | isa = PBXGroup; 164 | children = ( 165 | A14F6E6F1CA8FEC5006D8F51 /* AYPageControl.h */, 166 | A14F6E661CA8DC45006D8F51 /* AYCircleLayer.h */, 167 | A14F6E671CA8DC45006D8F51 /* AYCircleLayer.m */, 168 | A14F6E731CA902C4006D8F51 /* AYLineLayer.h */, 169 | A14F6E741CA902C4006D8F51 /* AYLineLayer.m */, 170 | A14F6E701CA902A0006D8F51 /* AYPageControlView.h */, 171 | A14F6E711CA902A0006D8F51 /* AYPageControlView.m */, 172 | ); 173 | path = AYPageControl; 174 | sourceTree = ""; 175 | }; 176 | /* End PBXGroup section */ 177 | 178 | /* Begin PBXNativeTarget section */ 179 | A14F6E2E1CA8DC26006D8F51 /* AYPageControl */ = { 180 | isa = PBXNativeTarget; 181 | buildConfigurationList = A14F6E5C1CA8DC27006D8F51 /* Build configuration list for PBXNativeTarget "AYPageControl" */; 182 | buildPhases = ( 183 | A14F6E2B1CA8DC26006D8F51 /* Sources */, 184 | A14F6E2C1CA8DC26006D8F51 /* Frameworks */, 185 | A14F6E2D1CA8DC26006D8F51 /* Resources */, 186 | ); 187 | buildRules = ( 188 | ); 189 | dependencies = ( 190 | ); 191 | name = AYPageControl; 192 | productName = AYPageControl; 193 | productReference = A14F6E2F1CA8DC26006D8F51 /* AYPageControl.app */; 194 | productType = "com.apple.product-type.application"; 195 | }; 196 | A14F6E471CA8DC26006D8F51 /* AYPageControlTests */ = { 197 | isa = PBXNativeTarget; 198 | buildConfigurationList = A14F6E5F1CA8DC27006D8F51 /* Build configuration list for PBXNativeTarget "AYPageControlTests" */; 199 | buildPhases = ( 200 | A14F6E441CA8DC26006D8F51 /* Sources */, 201 | A14F6E451CA8DC26006D8F51 /* Frameworks */, 202 | A14F6E461CA8DC26006D8F51 /* Resources */, 203 | ); 204 | buildRules = ( 205 | ); 206 | dependencies = ( 207 | A14F6E4A1CA8DC26006D8F51 /* PBXTargetDependency */, 208 | ); 209 | name = AYPageControlTests; 210 | productName = AYPageControlTests; 211 | productReference = A14F6E481CA8DC26006D8F51 /* AYPageControlTests.xctest */; 212 | productType = "com.apple.product-type.bundle.unit-test"; 213 | }; 214 | A14F6E521CA8DC27006D8F51 /* AYPageControlUITests */ = { 215 | isa = PBXNativeTarget; 216 | buildConfigurationList = A14F6E621CA8DC27006D8F51 /* Build configuration list for PBXNativeTarget "AYPageControlUITests" */; 217 | buildPhases = ( 218 | A14F6E4F1CA8DC27006D8F51 /* Sources */, 219 | A14F6E501CA8DC27006D8F51 /* Frameworks */, 220 | A14F6E511CA8DC27006D8F51 /* Resources */, 221 | ); 222 | buildRules = ( 223 | ); 224 | dependencies = ( 225 | A14F6E551CA8DC27006D8F51 /* PBXTargetDependency */, 226 | ); 227 | name = AYPageControlUITests; 228 | productName = AYPageControlUITests; 229 | productReference = A14F6E531CA8DC27006D8F51 /* AYPageControlUITests.xctest */; 230 | productType = "com.apple.product-type.bundle.ui-testing"; 231 | }; 232 | /* End PBXNativeTarget section */ 233 | 234 | /* Begin PBXProject section */ 235 | A14F6E271CA8DC26006D8F51 /* Project object */ = { 236 | isa = PBXProject; 237 | attributes = { 238 | LastUpgradeCheck = 0720; 239 | ORGANIZATIONNAME = Andy; 240 | TargetAttributes = { 241 | A14F6E2E1CA8DC26006D8F51 = { 242 | CreatedOnToolsVersion = 7.2; 243 | }; 244 | A14F6E471CA8DC26006D8F51 = { 245 | CreatedOnToolsVersion = 7.2; 246 | TestTargetID = A14F6E2E1CA8DC26006D8F51; 247 | }; 248 | A14F6E521CA8DC27006D8F51 = { 249 | CreatedOnToolsVersion = 7.2; 250 | TestTargetID = A14F6E2E1CA8DC26006D8F51; 251 | }; 252 | }; 253 | }; 254 | buildConfigurationList = A14F6E2A1CA8DC26006D8F51 /* Build configuration list for PBXProject "AYPageControl" */; 255 | compatibilityVersion = "Xcode 3.2"; 256 | developmentRegion = English; 257 | hasScannedForEncodings = 0; 258 | knownRegions = ( 259 | en, 260 | Base, 261 | ); 262 | mainGroup = A14F6E261CA8DC26006D8F51; 263 | productRefGroup = A14F6E301CA8DC26006D8F51 /* Products */; 264 | projectDirPath = ""; 265 | projectRoot = ""; 266 | targets = ( 267 | A14F6E2E1CA8DC26006D8F51 /* AYPageControl */, 268 | A14F6E471CA8DC26006D8F51 /* AYPageControlTests */, 269 | A14F6E521CA8DC27006D8F51 /* AYPageControlUITests */, 270 | ); 271 | }; 272 | /* End PBXProject section */ 273 | 274 | /* Begin PBXResourcesBuildPhase section */ 275 | A14F6E2D1CA8DC26006D8F51 /* Resources */ = { 276 | isa = PBXResourcesBuildPhase; 277 | buildActionMask = 2147483647; 278 | files = ( 279 | A14F6E421CA8DC26006D8F51 /* LaunchScreen.storyboard in Resources */, 280 | A14F6E3F1CA8DC26006D8F51 /* Assets.xcassets in Resources */, 281 | A14F6E3D1CA8DC26006D8F51 /* Main.storyboard in Resources */, 282 | ); 283 | runOnlyForDeploymentPostprocessing = 0; 284 | }; 285 | A14F6E461CA8DC26006D8F51 /* Resources */ = { 286 | isa = PBXResourcesBuildPhase; 287 | buildActionMask = 2147483647; 288 | files = ( 289 | ); 290 | runOnlyForDeploymentPostprocessing = 0; 291 | }; 292 | A14F6E511CA8DC27006D8F51 /* Resources */ = { 293 | isa = PBXResourcesBuildPhase; 294 | buildActionMask = 2147483647; 295 | files = ( 296 | ); 297 | runOnlyForDeploymentPostprocessing = 0; 298 | }; 299 | /* End PBXResourcesBuildPhase section */ 300 | 301 | /* Begin PBXSourcesBuildPhase section */ 302 | A14F6E2B1CA8DC26006D8F51 /* Sources */ = { 303 | isa = PBXSourcesBuildPhase; 304 | buildActionMask = 2147483647; 305 | files = ( 306 | A14F6E751CA902C4006D8F51 /* AYLineLayer.m in Sources */, 307 | A14F6E3A1CA8DC26006D8F51 /* ViewController.m in Sources */, 308 | A14F6E371CA8DC26006D8F51 /* AppDelegate.m in Sources */, 309 | A14F6E341CA8DC26006D8F51 /* main.m in Sources */, 310 | A14F6E6A1CA8DC45006D8F51 /* AYCircleLayer.m in Sources */, 311 | A14F6E721CA902A0006D8F51 /* AYPageControlView.m in Sources */, 312 | ); 313 | runOnlyForDeploymentPostprocessing = 0; 314 | }; 315 | A14F6E441CA8DC26006D8F51 /* Sources */ = { 316 | isa = PBXSourcesBuildPhase; 317 | buildActionMask = 2147483647; 318 | files = ( 319 | A14F6E4D1CA8DC27006D8F51 /* AYPageControlTests.m in Sources */, 320 | ); 321 | runOnlyForDeploymentPostprocessing = 0; 322 | }; 323 | A14F6E4F1CA8DC27006D8F51 /* Sources */ = { 324 | isa = PBXSourcesBuildPhase; 325 | buildActionMask = 2147483647; 326 | files = ( 327 | A14F6E581CA8DC27006D8F51 /* AYPageControlUITests.m in Sources */, 328 | ); 329 | runOnlyForDeploymentPostprocessing = 0; 330 | }; 331 | /* End PBXSourcesBuildPhase section */ 332 | 333 | /* Begin PBXTargetDependency section */ 334 | A14F6E4A1CA8DC26006D8F51 /* PBXTargetDependency */ = { 335 | isa = PBXTargetDependency; 336 | target = A14F6E2E1CA8DC26006D8F51 /* AYPageControl */; 337 | targetProxy = A14F6E491CA8DC26006D8F51 /* PBXContainerItemProxy */; 338 | }; 339 | A14F6E551CA8DC27006D8F51 /* PBXTargetDependency */ = { 340 | isa = PBXTargetDependency; 341 | target = A14F6E2E1CA8DC26006D8F51 /* AYPageControl */; 342 | targetProxy = A14F6E541CA8DC27006D8F51 /* PBXContainerItemProxy */; 343 | }; 344 | /* End PBXTargetDependency section */ 345 | 346 | /* Begin PBXVariantGroup section */ 347 | A14F6E3B1CA8DC26006D8F51 /* Main.storyboard */ = { 348 | isa = PBXVariantGroup; 349 | children = ( 350 | A14F6E3C1CA8DC26006D8F51 /* Base */, 351 | ); 352 | name = Main.storyboard; 353 | sourceTree = ""; 354 | }; 355 | A14F6E401CA8DC26006D8F51 /* LaunchScreen.storyboard */ = { 356 | isa = PBXVariantGroup; 357 | children = ( 358 | A14F6E411CA8DC26006D8F51 /* Base */, 359 | ); 360 | name = LaunchScreen.storyboard; 361 | sourceTree = ""; 362 | }; 363 | /* End PBXVariantGroup section */ 364 | 365 | /* Begin XCBuildConfiguration section */ 366 | A14F6E5A1CA8DC27006D8F51 /* Debug */ = { 367 | isa = XCBuildConfiguration; 368 | buildSettings = { 369 | ALWAYS_SEARCH_USER_PATHS = NO; 370 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 371 | CLANG_CXX_LIBRARY = "libc++"; 372 | CLANG_ENABLE_MODULES = YES; 373 | CLANG_ENABLE_OBJC_ARC = YES; 374 | CLANG_WARN_BOOL_CONVERSION = YES; 375 | CLANG_WARN_CONSTANT_CONVERSION = YES; 376 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 377 | CLANG_WARN_EMPTY_BODY = YES; 378 | CLANG_WARN_ENUM_CONVERSION = YES; 379 | CLANG_WARN_INT_CONVERSION = YES; 380 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 381 | CLANG_WARN_UNREACHABLE_CODE = YES; 382 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 383 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 384 | COPY_PHASE_STRIP = NO; 385 | DEBUG_INFORMATION_FORMAT = dwarf; 386 | ENABLE_STRICT_OBJC_MSGSEND = YES; 387 | ENABLE_TESTABILITY = YES; 388 | GCC_C_LANGUAGE_STANDARD = gnu99; 389 | GCC_DYNAMIC_NO_PIC = NO; 390 | GCC_NO_COMMON_BLOCKS = YES; 391 | GCC_OPTIMIZATION_LEVEL = 0; 392 | GCC_PREPROCESSOR_DEFINITIONS = ( 393 | "DEBUG=1", 394 | "$(inherited)", 395 | ); 396 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 397 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 398 | GCC_WARN_UNDECLARED_SELECTOR = YES; 399 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 400 | GCC_WARN_UNUSED_FUNCTION = YES; 401 | GCC_WARN_UNUSED_VARIABLE = YES; 402 | IPHONEOS_DEPLOYMENT_TARGET = 9.2; 403 | MTL_ENABLE_DEBUG_INFO = YES; 404 | ONLY_ACTIVE_ARCH = YES; 405 | SDKROOT = iphoneos; 406 | }; 407 | name = Debug; 408 | }; 409 | A14F6E5B1CA8DC27006D8F51 /* Release */ = { 410 | isa = XCBuildConfiguration; 411 | buildSettings = { 412 | ALWAYS_SEARCH_USER_PATHS = NO; 413 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 414 | CLANG_CXX_LIBRARY = "libc++"; 415 | CLANG_ENABLE_MODULES = YES; 416 | CLANG_ENABLE_OBJC_ARC = YES; 417 | CLANG_WARN_BOOL_CONVERSION = YES; 418 | CLANG_WARN_CONSTANT_CONVERSION = YES; 419 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 420 | CLANG_WARN_EMPTY_BODY = YES; 421 | CLANG_WARN_ENUM_CONVERSION = YES; 422 | CLANG_WARN_INT_CONVERSION = YES; 423 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 424 | CLANG_WARN_UNREACHABLE_CODE = YES; 425 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 426 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 427 | COPY_PHASE_STRIP = NO; 428 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 429 | ENABLE_NS_ASSERTIONS = NO; 430 | ENABLE_STRICT_OBJC_MSGSEND = YES; 431 | GCC_C_LANGUAGE_STANDARD = gnu99; 432 | GCC_NO_COMMON_BLOCKS = YES; 433 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 434 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 435 | GCC_WARN_UNDECLARED_SELECTOR = YES; 436 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 437 | GCC_WARN_UNUSED_FUNCTION = YES; 438 | GCC_WARN_UNUSED_VARIABLE = YES; 439 | IPHONEOS_DEPLOYMENT_TARGET = 9.2; 440 | MTL_ENABLE_DEBUG_INFO = NO; 441 | SDKROOT = iphoneos; 442 | VALIDATE_PRODUCT = YES; 443 | }; 444 | name = Release; 445 | }; 446 | A14F6E5D1CA8DC27006D8F51 /* Debug */ = { 447 | isa = XCBuildConfiguration; 448 | buildSettings = { 449 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 450 | INFOPLIST_FILE = AYPageControl/Info.plist; 451 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 452 | PRODUCT_BUNDLE_IDENTIFIER = com.Andy.AYPageControl; 453 | PRODUCT_NAME = "$(TARGET_NAME)"; 454 | }; 455 | name = Debug; 456 | }; 457 | A14F6E5E1CA8DC27006D8F51 /* Release */ = { 458 | isa = XCBuildConfiguration; 459 | buildSettings = { 460 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 461 | INFOPLIST_FILE = AYPageControl/Info.plist; 462 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 463 | PRODUCT_BUNDLE_IDENTIFIER = com.Andy.AYPageControl; 464 | PRODUCT_NAME = "$(TARGET_NAME)"; 465 | }; 466 | name = Release; 467 | }; 468 | A14F6E601CA8DC27006D8F51 /* Debug */ = { 469 | isa = XCBuildConfiguration; 470 | buildSettings = { 471 | BUNDLE_LOADER = "$(TEST_HOST)"; 472 | INFOPLIST_FILE = AYPageControlTests/Info.plist; 473 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 474 | PRODUCT_BUNDLE_IDENTIFIER = com.Andy.AYPageControlTests; 475 | PRODUCT_NAME = "$(TARGET_NAME)"; 476 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/AYPageControl.app/AYPageControl"; 477 | }; 478 | name = Debug; 479 | }; 480 | A14F6E611CA8DC27006D8F51 /* Release */ = { 481 | isa = XCBuildConfiguration; 482 | buildSettings = { 483 | BUNDLE_LOADER = "$(TEST_HOST)"; 484 | INFOPLIST_FILE = AYPageControlTests/Info.plist; 485 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 486 | PRODUCT_BUNDLE_IDENTIFIER = com.Andy.AYPageControlTests; 487 | PRODUCT_NAME = "$(TARGET_NAME)"; 488 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/AYPageControl.app/AYPageControl"; 489 | }; 490 | name = Release; 491 | }; 492 | A14F6E631CA8DC27006D8F51 /* Debug */ = { 493 | isa = XCBuildConfiguration; 494 | buildSettings = { 495 | INFOPLIST_FILE = AYPageControlUITests/Info.plist; 496 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 497 | PRODUCT_BUNDLE_IDENTIFIER = com.Andy.AYPageControlUITests; 498 | PRODUCT_NAME = "$(TARGET_NAME)"; 499 | TEST_TARGET_NAME = AYPageControl; 500 | USES_XCTRUNNER = YES; 501 | }; 502 | name = Debug; 503 | }; 504 | A14F6E641CA8DC27006D8F51 /* Release */ = { 505 | isa = XCBuildConfiguration; 506 | buildSettings = { 507 | INFOPLIST_FILE = AYPageControlUITests/Info.plist; 508 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 509 | PRODUCT_BUNDLE_IDENTIFIER = com.Andy.AYPageControlUITests; 510 | PRODUCT_NAME = "$(TARGET_NAME)"; 511 | TEST_TARGET_NAME = AYPageControl; 512 | USES_XCTRUNNER = YES; 513 | }; 514 | name = Release; 515 | }; 516 | /* End XCBuildConfiguration section */ 517 | 518 | /* Begin XCConfigurationList section */ 519 | A14F6E2A1CA8DC26006D8F51 /* Build configuration list for PBXProject "AYPageControl" */ = { 520 | isa = XCConfigurationList; 521 | buildConfigurations = ( 522 | A14F6E5A1CA8DC27006D8F51 /* Debug */, 523 | A14F6E5B1CA8DC27006D8F51 /* Release */, 524 | ); 525 | defaultConfigurationIsVisible = 0; 526 | defaultConfigurationName = Release; 527 | }; 528 | A14F6E5C1CA8DC27006D8F51 /* Build configuration list for PBXNativeTarget "AYPageControl" */ = { 529 | isa = XCConfigurationList; 530 | buildConfigurations = ( 531 | A14F6E5D1CA8DC27006D8F51 /* Debug */, 532 | A14F6E5E1CA8DC27006D8F51 /* Release */, 533 | ); 534 | defaultConfigurationIsVisible = 0; 535 | defaultConfigurationName = Release; 536 | }; 537 | A14F6E5F1CA8DC27006D8F51 /* Build configuration list for PBXNativeTarget "AYPageControlTests" */ = { 538 | isa = XCConfigurationList; 539 | buildConfigurations = ( 540 | A14F6E601CA8DC27006D8F51 /* Debug */, 541 | A14F6E611CA8DC27006D8F51 /* Release */, 542 | ); 543 | defaultConfigurationIsVisible = 0; 544 | defaultConfigurationName = Release; 545 | }; 546 | A14F6E621CA8DC27006D8F51 /* Build configuration list for PBXNativeTarget "AYPageControlUITests" */ = { 547 | isa = XCConfigurationList; 548 | buildConfigurations = ( 549 | A14F6E631CA8DC27006D8F51 /* Debug */, 550 | A14F6E641CA8DC27006D8F51 /* Release */, 551 | ); 552 | defaultConfigurationIsVisible = 0; 553 | defaultConfigurationName = Release; 554 | }; 555 | /* End XCConfigurationList section */ 556 | }; 557 | rootObject = A14F6E271CA8DC26006D8F51 /* Project object */; 558 | } 559 | -------------------------------------------------------------------------------- /AYPageControl.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /AYPageControl/AYPageControl/AYCircleLayer.h: -------------------------------------------------------------------------------- 1 | // 2 | // AYCircleLayer.h 3 | // AYAnimaPageController 4 | // 5 | // Created by Andy on 16/3/25. 6 | // Copyright © 2016年 Andy. All rights reserved. 7 | // 8 | 9 | #import 10 | #import 11 | @interface AYCircleLayer : CALayer 12 | 13 | /** 14 | * 当前progress 15 | */ 16 | @property (nonatomic, assign) CGFloat currentProgress; 17 | /** 18 | * 外界矩形大小 19 | */ 20 | @property (nonatomic, assign) CGRect outsideRect; 21 | 22 | @property (nonatomic, assign) CGFloat contentOffset_x; 23 | @property (nonatomic, assign) CGFloat lastContentOffset_x; 24 | /** 25 | * 页面的个数 26 | */ 27 | @property (nonatomic, assign) NSInteger numberOfPages; 28 | /** 29 | * 当前页码 30 | */ 31 | @property (nonatomic, assign) NSInteger currentPage; 32 | /** 33 | * pageControl绑定scrollView的宽度 34 | */ 35 | @property (nonatomic, assign) CGFloat bingdingScrollViewWidth; 36 | /** 37 | * 选中的颜色 38 | */ 39 | @property (nonatomic, strong) UIColor *selectedColor; 40 | @end 41 | -------------------------------------------------------------------------------- /AYPageControl/AYPageControl/AYCircleLayer.m: -------------------------------------------------------------------------------- 1 | // 2 | // AYCircleLayer.m 3 | // AYAnimaPageController 4 | // 5 | // Created by Andy on 16/3/25. 6 | // Copyright © 2016年 Andy. All rights reserved. 7 | // 8 | 9 | #import "AYCircleLayer.h" 10 | 11 | #define AnimaBallDistance self.frame.size.width / (self.numberOfPages + 1) 12 | /** 13 | 动画向左或右移动 14 | */ 15 | typedef enum : NSUInteger { 16 | Move_Left, 17 | Move_Right, 18 | } Move_Direction; 19 | 20 | @interface AYCircleLayer () 21 | /** 22 | * 移动方向 23 | */ 24 | @property (nonatomic, assign) Move_Direction moveDirection; 25 | @property (nonatomic, assign) CGFloat outsideRectSize; 26 | @property (nonatomic, assign) CGFloat factor; 27 | /** 28 | * 查询,设置是否要切换当前的currentPage 29 | */ 30 | //@property (nonatomic, assign, getter=isNeedChangepage) BOOL needChangePage; 31 | @end 32 | 33 | @implementation AYCircleLayer 34 | 35 | - (instancetype)init { 36 | 37 | if (self = [super init]) { 38 | self.outsideRectSize = 10; 39 | self.currentProgress = 0; 40 | self.currentPage = 1; 41 | } 42 | return self; 43 | } 44 | 45 | - (instancetype)initWithLayer:(AYCircleLayer *)layer { 46 | 47 | if (self = [super initWithLayer:layer]) { 48 | self.currentProgress = layer.currentProgress; 49 | self.outsideRect = layer.outsideRect; 50 | self.outsideRectSize = layer.outsideRectSize; 51 | self.currentPage = layer.currentPage; 52 | } 53 | return self; 54 | } 55 | 56 | - (void)setLastContentOffset_x:(CGFloat)lastContentOffset_x { 57 | 58 | _lastContentOffset_x = lastContentOffset_x; 59 | // self.currentProgress = 0; 60 | // [self setNeedsDisplay]; 61 | } 62 | 63 | - (void)setContentOffset_x:(CGFloat)contentOffset_x { 64 | 65 | _contentOffset_x = contentOffset_x; 66 | 67 | if (_contentOffset_x - _lastContentOffset_x > 0) { 68 | self.moveDirection = Move_Right; 69 | if (_contentOffset_x <= _bingdingScrollViewWidth * ((self.lastContentOffset_x / _bingdingScrollViewWidth) + .5)) { 70 | _currentProgress = MIN(1, MAX(0, (ABS(contentOffset_x - _lastContentOffset_x) / _bingdingScrollViewWidth))); 71 | } else { 72 | _currentProgress = 1 - MIN(1, MAX(0, (ABS(contentOffset_x - _lastContentOffset_x) / _bingdingScrollViewWidth))); 73 | } 74 | } else if (_contentOffset_x - _lastContentOffset_x <= 0) { 75 | NSInteger lastPage = (_contentOffset_x / _bingdingScrollViewWidth + 2); 76 | 77 | self.moveDirection = Move_Left; 78 | if (_contentOffset_x < lastPage * _bingdingScrollViewWidth - _bingdingScrollViewWidth * 1.5 && _contentOffset_x > 0) { 79 | _currentProgress = 1 - MIN(1, MAX(0, (ABS(contentOffset_x - _lastContentOffset_x) / _bingdingScrollViewWidth))); 80 | } else { 81 | _currentProgress = MIN(1, MAX(0, (ABS(contentOffset_x - _lastContentOffset_x) / _bingdingScrollViewWidth))); 82 | } 83 | if (_currentProgress > .9) { 84 | _currentProgress = 0; 85 | } 86 | } 87 | CGFloat origin_x = (self.contentOffset_x / _bingdingScrollViewWidth)*(self.frame.size.width / (_numberOfPages + 1)) + AnimaBallDistance - self.outsideRectSize * .5; 88 | CGFloat origin_y = self.position.y - self.outsideRectSize * .5; 89 | self.outsideRect = CGRectMake(origin_x, origin_y, self.outsideRectSize, self.outsideRectSize); 90 | 91 | [self setNeedsDisplay]; 92 | } 93 | 94 | - (void)drawInContext:(CGContextRef)ctx { 95 | 96 | // 计算出偏移值 97 | CGFloat offset = self.outsideRect.size.width / 3.6; 98 | // 计算出移动距离 99 | CGFloat moveDistance = (self.outsideRect.size.width / 6) * fabs(self.currentProgress) * 2; 100 | // 计算出中心点坐标 101 | CGPoint rectCenter = CGPointMake(self.outsideRect.origin.x + self.outsideRect.size.width * .5, self.outsideRect.origin.y + self.outsideRect.size.height * .5); 102 | // 计算各个辅助点坐标 103 | CGPoint point_A = CGPointMake(rectCenter.x,self.outsideRect.origin.y + moveDistance); 104 | CGPoint point_B = CGPointMake(self.moveDirection == Move_Right ? rectCenter.x + self.outsideRect.size.width * .5:self.outsideRect.size.width * .5 + rectCenter.x + moveDistance * 2, rectCenter.y); 105 | CGPoint point_C = CGPointMake(rectCenter.x, rectCenter.y + self.outsideRect.size.width * .5 - moveDistance); 106 | CGPoint point_D = CGPointMake(self.moveDirection == Move_Right ? self.outsideRect.origin.x - moveDistance * 2:self.outsideRect.origin.x, rectCenter.y); 107 | CGPoint point_c1 = CGPointMake(point_A.x + offset, point_A.y); 108 | CGPoint point_c2 = CGPointMake(point_B.x,self.moveDirection == Move_Right ? point_B.y - offset:point_B.y - offset + moveDistance); 109 | CGPoint point_c3 = CGPointMake(point_B.x, self.moveDirection == Move_Right ? point_B.y + offset:point_B.y + offset - moveDistance); 110 | CGPoint point_c4 = CGPointMake(point_C.x + offset, point_C.y); 111 | CGPoint point_c5 = CGPointMake(point_C.x - offset, point_C.y); 112 | CGPoint point_c6 = CGPointMake(point_D.x, self.moveDirection == Move_Right ? point_D.y + offset - moveDistance:point_D.y + offset); 113 | CGPoint point_c7 = CGPointMake(point_D.x, self.moveDirection == Move_Right ? point_D.y - offset + moveDistance:point_D.y - offset); 114 | CGPoint point_c8 = CGPointMake(point_A.x - offset,point_A.y); 115 | // 圆的边界 116 | UIBezierPath *ovalPath = [UIBezierPath bezierPath]; 117 | [ovalPath moveToPoint:point_A]; 118 | [ovalPath addCurveToPoint:point_B controlPoint1:point_c1 controlPoint2:point_c2]; 119 | [ovalPath addCurveToPoint:point_C controlPoint1:point_c3 controlPoint2:point_c4]; 120 | [ovalPath addCurveToPoint:point_D controlPoint1:point_c5 controlPoint2:point_c6]; 121 | [ovalPath addCurveToPoint:point_A controlPoint1:point_c7 controlPoint2:point_c8]; 122 | [ovalPath closePath]; 123 | CGContextAddPath(ctx, ovalPath.CGPath); 124 | // CGContextSetStrokeColorWithColor(ctx, [UIColor blackColor].CGColor); 125 | CGContextSetFillColorWithColor(ctx, self.selectedColor.CGColor); 126 | CGContextFillPath(ctx); 127 | } 128 | 129 | @end 130 | -------------------------------------------------------------------------------- /AYPageControl/AYPageControl/AYLineLayer.h: -------------------------------------------------------------------------------- 1 | // 2 | // AYLineLayer.h 3 | // AYPageControl 4 | // 5 | // Created by Andy on 16/3/28. 6 | // Copyright © 2016年 Andy. All rights reserved. 7 | // 8 | 9 | #import 10 | #import 11 | @interface AYLineLayer : CALayer 12 | /** 13 | * 页面的个数 14 | */ 15 | @property (nonatomic, assign) NSInteger numberOfPages; 16 | /** 17 | * 当前页码 18 | */ 19 | @property (nonatomic, assign) NSInteger currentPage; 20 | /** 21 | * 圆圈直径 22 | */ 23 | @property (nonatomic, assign) CGFloat ballDiameter; 24 | 25 | /** 26 | * 未选中的颜色 27 | */ 28 | @property (nonatomic, strong) UIColor *unSelectedColor; 29 | /** 30 | * pageControl绑定的scrollview 31 | */ 32 | @property (nonatomic, strong) UIScrollView *bindingScrollView; 33 | @end 34 | -------------------------------------------------------------------------------- /AYPageControl/AYPageControl/AYLineLayer.m: -------------------------------------------------------------------------------- 1 | // 2 | // AYLineLayer.m 3 | // AYPageControl 4 | // 5 | // Created by Andy on 16/3/28. 6 | // Copyright © 2016年 Andy. All rights reserved. 7 | // 8 | 9 | #import "AYLineLayer.h" 10 | #define BallCenterDistance self.frame.size.width / (self.numberOfPages + 1) 11 | 12 | @interface AYLineLayer () 13 | /** 14 | * 选中的颜色 15 | */ 16 | @property (nonatomic, strong) UIColor *selectedColor; 17 | @end 18 | 19 | @implementation AYLineLayer 20 | 21 | - (instancetype)init { 22 | 23 | if (self = [super init]) { 24 | self.numberOfPages = 3; 25 | self.currentPage = 1; 26 | self.ballDiameter = 10.0; 27 | self.unSelectedColor = [UIColor lightGrayColor]; 28 | self.selectedColor = [UIColor clearColor]; 29 | } 30 | return self; 31 | } 32 | /** 33 | * 必须重载,调用drawInContext前必定调用此方法获取上一个状态 34 | */ 35 | - (instancetype)initWithLayer:(AYLineLayer *)layer { 36 | 37 | if (self = [super initWithLayer:layer]) { 38 | self.numberOfPages = layer.numberOfPages; 39 | self.currentPage = layer.currentPage; 40 | self.ballDiameter = layer.ballDiameter; 41 | } 42 | return self; 43 | } 44 | 45 | - (void)setNumberOfPages:(NSInteger)numberOfPages { 46 | 47 | _numberOfPages = numberOfPages; 48 | [self setNeedsDisplay]; 49 | } 50 | 51 | - (void)setCurrentPage:(NSInteger)currentPage { 52 | 53 | if (_currentPage != currentPage) { 54 | _currentPage = currentPage; 55 | if (_currentPage <= 0) { 56 | _currentPage = 1; 57 | } 58 | if (_currentPage >= _numberOfPages + 1) { 59 | _currentPage = _numberOfPages; 60 | } 61 | [self setNeedsDisplay]; 62 | } 63 | } 64 | /** 65 | * 当调用setNeedsDisplay时触发drawInContext: 66 | */ 67 | - (void)drawInContext:(CGContextRef)ctx { 68 | 69 | CGMutablePathRef linePath = CGPathCreateMutable(); 70 | // 画圆操作 71 | for (int index = 0; index < self.numberOfPages; index ++) { 72 | if (index == self.currentPage - 1) { 73 | continue; 74 | } 75 | CGPathAddEllipseInRect(linePath, NULL, CGRectMake((index + 1)* BallCenterDistance - self.ballDiameter * .5, self.frame.size.height * .5 - self.ballDiameter * .5, self.ballDiameter, self.ballDiameter)); 76 | } 77 | CGContextAddPath(ctx, linePath); 78 | CGContextSetFillColorWithColor(ctx, self.unSelectedColor.CGColor); 79 | CGContextFillPath(ctx); 80 | 81 | // CGMutablePathRef firtstLinePath = CGPathCreateMutable(); 82 | // CGPathAddEllipseInRect(firtstLinePath, NULL, CGRectMake((self.currentPage - 1) * (ballDistance + self.ballDiameter * .5) + ballDistance, self.frame.size.height * .5 - self.ballDiameter * .5, self.ballDiameter, self.ballDiameter)); 83 | // CGContextAddPath(ctx, firtstLinePath); 84 | // CGContextSetFillColorWithColor(ctx, self.selectedColor.CGColor); 85 | // CGContextFillPath(ctx); 86 | } 87 | 88 | @end 89 | -------------------------------------------------------------------------------- /AYPageControl/AYPageControl/AYPageControl.h: -------------------------------------------------------------------------------- 1 | // 2 | // AYPageControl.h 3 | // AYPageControl 4 | // 5 | // Created by Andy on 16/3/28. 6 | // Copyright © 2016年 Andy. All rights reserved. 7 | // 8 | 9 | #ifndef AYPageControl_h 10 | #define AYPageControl_h 11 | 12 | #import "AYPageControlView.h" 13 | 14 | #endif /* AYPageControl_h */ 15 | -------------------------------------------------------------------------------- /AYPageControl/AYPageControl/AYPageControlView.h: -------------------------------------------------------------------------------- 1 | // 2 | // AYPageControlView.h 3 | // AYPageControl 4 | // 5 | // Created by Andy on 16/3/28. 6 | // Copyright © 2016年 Andy. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "AYLineLayer.h" 11 | @interface AYPageControlView : UIView 12 | /** 13 | * 背景横线视图 14 | */ 15 | @property (nonatomic, strong) AYLineLayer *lineLayer; 16 | /** 17 | * 页面的个数 18 | */ 19 | @property (nonatomic, assign) NSInteger numberOfPages; 20 | /** 21 | * 当前页码 22 | */ 23 | @property (nonatomic, assign) NSInteger currentPage; 24 | /** 25 | * 圆圈直径 26 | */ 27 | @property (nonatomic, assign) CGFloat ballDiameter; 28 | /** 29 | * 选中的颜色 30 | */ 31 | @property (nonatomic, strong) UIColor *selectedColor; 32 | /** 33 | * 未选中的颜色 34 | */ 35 | @property (nonatomic, strong) UIColor *unSelectedColor; 36 | /** 37 | * pageControl绑定的scrollview 38 | */ 39 | @property (nonatomic, strong) UIScrollView *bindingScrollView; 40 | /** 41 | * 绑定的scrollView的cotentOffset.x 42 | */ 43 | @property (nonatomic, assign) CGFloat contentOffset_x; 44 | /** 45 | * 绑定的scrollView的lastCotentOffset.x 46 | */ 47 | @property (nonatomic, assign) CGFloat lastContentOffset_x; 48 | @end 49 | -------------------------------------------------------------------------------- /AYPageControl/AYPageControl/AYPageControlView.m: -------------------------------------------------------------------------------- 1 | // 2 | // AYPageControlView.m 3 | // AYPageControl 4 | // 5 | // Created by Andy on 16/3/28. 6 | // Copyright © 2016年 Andy. All rights reserved. 7 | // 8 | 9 | #import "AYPageControlView.h" 10 | #import "AYCircleLayer.h" 11 | 12 | @interface AYPageControlView () 13 | 14 | @property (nonatomic, strong) AYCircleLayer *circleLayer; 15 | 16 | @end 17 | 18 | @implementation AYPageControlView 19 | 20 | 21 | 22 | - (void)setCurrentPage:(NSInteger)currentPage { 23 | 24 | if (_currentPage != currentPage) { 25 | _currentPage = currentPage; 26 | self.lineLayer.currentPage = _currentPage; 27 | self.circleLayer.currentPage = _currentPage; 28 | } 29 | } 30 | 31 | - (void)setContentOffset_x:(CGFloat)contentOffset_x { 32 | 33 | if (_contentOffset_x != contentOffset_x) { 34 | _contentOffset_x = contentOffset_x; 35 | self.circleLayer.contentOffset_x = self.contentOffset_x; 36 | [self calculateProgress]; 37 | } 38 | } 39 | 40 | - (void)setNumberOfPages:(NSInteger)numberOfPages { 41 | 42 | _numberOfPages = numberOfPages; 43 | self.lineLayer.numberOfPages = _numberOfPages; 44 | self.circleLayer.numberOfPages = _numberOfPages; 45 | } 46 | 47 | - (void)setLastContentOffset_x:(CGFloat)lastContentOffset_x { 48 | 49 | _lastContentOffset_x = lastContentOffset_x; 50 | self.circleLayer.lastContentOffset_x = _lastContentOffset_x; 51 | } 52 | 53 | - (void)calculateProgress { 54 | 55 | CGFloat pageWidth = self.bindingScrollView.frame.size.width; 56 | int currentPage = floor((self.contentOffset_x - pageWidth * .5) / pageWidth) + 2; 57 | self.currentPage = currentPage; 58 | } 59 | 60 | - (void)setBindingScrollView:(UIScrollView *)bindingScrollView { 61 | 62 | _bindingScrollView = bindingScrollView; 63 | self.circleLayer.bingdingScrollViewWidth = _bindingScrollView.frame.size.width; 64 | self.circleLayer.contentOffset_x = 0; 65 | 66 | } 67 | 68 | - (void)setSelectedColor:(UIColor *)selectedColor { 69 | 70 | _selectedColor = selectedColor; 71 | self.circleLayer.selectedColor = _selectedColor; 72 | } 73 | 74 | - (void)setUnSelectedColor:(UIColor *)unSelectedColor { 75 | 76 | _unSelectedColor = unSelectedColor; 77 | self.lineLayer.unSelectedColor = unSelectedColor; 78 | } 79 | 80 | - (instancetype)initWithFrame:(CGRect)frame { 81 | 82 | if (self = [super initWithFrame:frame]) { 83 | [self configCircleView:frame]; 84 | } 85 | return self; 86 | } 87 | 88 | - (void)configCircleView:(CGRect)frame { 89 | 90 | self.lineLayer = [AYLineLayer layer]; 91 | self.lineLayer.frame = CGRectMake(0, 0, frame.size.width, frame.size.height); 92 | self.lineLayer.contentsScale = [UIScreen mainScreen].scale; 93 | self.lineLayer.bindingScrollView = self.bindingScrollView; 94 | [self.layer addSublayer:self.lineLayer]; 95 | 96 | self.circleLayer = [AYCircleLayer layer]; 97 | self.circleLayer.frame = CGRectMake(0, 0, frame.size.width, frame.size.height); 98 | self.circleLayer.contentsScale = [UIScreen mainScreen].scale; 99 | [self.layer addSublayer:self.circleLayer]; 100 | } 101 | 102 | @end 103 | -------------------------------------------------------------------------------- /AYPageControl/AppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.h 3 | // AYPageControl 4 | // 5 | // Created by Andy on 16/3/28. 6 | // Copyright © 2016年 Andy. 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 | -------------------------------------------------------------------------------- /AYPageControl/AppDelegate.m: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.m 3 | // AYPageControl 4 | // 5 | // Created by Andy on 16/3/28. 6 | // Copyright © 2016年 Andy. All rights reserved. 7 | // 8 | 9 | #import "AppDelegate.h" 10 | 11 | @interface AppDelegate () 12 | 13 | @end 14 | 15 | @implementation AppDelegate 16 | 17 | 18 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { 19 | // Override point for customization after application launch. 20 | return YES; 21 | } 22 | 23 | - (void)applicationWillResignActive:(UIApplication *)application { 24 | // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. 25 | // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game. 26 | } 27 | 28 | - (void)applicationDidEnterBackground:(UIApplication *)application { 29 | // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. 30 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 31 | } 32 | 33 | - (void)applicationWillEnterForeground:(UIApplication *)application { 34 | // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background. 35 | } 36 | 37 | - (void)applicationDidBecomeActive:(UIApplication *)application { 38 | // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. 39 | } 40 | 41 | - (void)applicationWillTerminate:(UIApplication *)application { 42 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 43 | } 44 | 45 | @end 46 | -------------------------------------------------------------------------------- /AYPageControl/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 | } -------------------------------------------------------------------------------- /AYPageControl/Assets.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "version" : 1, 4 | "author" : "xcode" 5 | } 6 | } -------------------------------------------------------------------------------- /AYPageControl/Assets.xcassets/blog.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "blog.png", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "scale" : "3x" 15 | } 16 | ], 17 | "info" : { 18 | "version" : 1, 19 | "author" : "xcode" 20 | } 21 | } -------------------------------------------------------------------------------- /AYPageControl/Assets.xcassets/blog.imageset/blog.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AYJk/AYPageControl/3d0c643a8366534a7f03cc8ee2a35624e7f4252d/AYPageControl/Assets.xcassets/blog.imageset/blog.png -------------------------------------------------------------------------------- /AYPageControl/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 | -------------------------------------------------------------------------------- /AYPageControl/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 | -------------------------------------------------------------------------------- /AYPageControl/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 | -------------------------------------------------------------------------------- /AYPageControl/ViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.h 3 | // AYPageControl 4 | // 5 | // Created by Andy on 16/3/28. 6 | // Copyright © 2016年 Andy. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface ViewController : UIViewController 12 | 13 | 14 | @end 15 | 16 | -------------------------------------------------------------------------------- /AYPageControl/ViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.m 3 | // AYAnimaPageController 4 | // 5 | // Created by Andy on 16/3/25. 6 | // Copyright © 2016年 Andy. All rights reserved. 7 | // 8 | 9 | #import "ViewController.h" 10 | #import "AYPageControl.h" 11 | #define totalPages 6 12 | @interface ViewController () 13 | 14 | @property (nonatomic, strong) AYPageControlView *pageControlView; 15 | @property (nonatomic, strong) UIScrollView *bannerScrollView; 16 | 17 | @end 18 | 19 | @implementation ViewController 20 | 21 | - (void)viewDidLoad { 22 | [super viewDidLoad]; 23 | 24 | self.bannerScrollView = ({ 25 | UIScrollView *scrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 64, self.view.frame.size.width, 120)]; 26 | scrollView.showsVerticalScrollIndicator = NO; 27 | scrollView.showsHorizontalScrollIndicator = NO; 28 | scrollView.contentSize = CGSizeMake(totalPages * self.view.frame.size.width, 120); 29 | for (int index = 0; index < totalPages; index ++) { 30 | UIImageView *bannerImageView = ({ 31 | UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake(index * self.view.frame.size.width, 0, self.view.frame.size.width, 120)]; 32 | imageView.image = [UIImage imageNamed:@"blog"]; 33 | [scrollView addSubview:imageView]; 34 | imageView; 35 | }); 36 | } 37 | scrollView.delegate = self; 38 | scrollView.pagingEnabled = YES; 39 | [self.view addSubview:scrollView]; 40 | scrollView; 41 | }); 42 | self.pageControlView = [[AYPageControlView alloc] initWithFrame:CGRectMake((self.view.frame.size.width - 300) * .5, 200, 300, 40)]; 43 | self.pageControlView.numberOfPages = totalPages; 44 | self.pageControlView.bindingScrollView = self.bannerScrollView; 45 | self.pageControlView.selectedColor = [UIColor blackColor]; 46 | self.pageControlView.unSelectedColor = [UIColor lightGrayColor]; 47 | self.pageControlView.backgroundColor = [UIColor colorWithRed:22/255.0 green:170/255.0 blue:100/255.0 alpha:1]; 48 | [self.view addSubview:self.pageControlView]; 49 | } 50 | 51 | - (void)scrollViewDidScroll:(UIScrollView *)scrollView { 52 | 53 | self.pageControlView.contentOffset_x = scrollView.contentOffset.x; 54 | } 55 | 56 | - (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView { 57 | 58 | self.pageControlView.lastContentOffset_x = scrollView.contentOffset.x; 59 | } 60 | 61 | - (void)scrollViewDidEndScrollingAnimation:(UIScrollView *)scrollView { 62 | 63 | self.pageControlView.lastContentOffset_x = scrollView.contentOffset.x; 64 | } 65 | 66 | - (void)didReceiveMemoryWarning { 67 | [super didReceiveMemoryWarning]; 68 | // Dispose of any resources that can be recreated. 69 | } 70 | 71 | @end -------------------------------------------------------------------------------- /AYPageControl/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // AYPageControl 4 | // 5 | // Created by Andy on 16/3/28. 6 | // Copyright © 2016年 Andy. 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 | -------------------------------------------------------------------------------- /AYPageControlTests/AYPageControlTests.m: -------------------------------------------------------------------------------- 1 | // 2 | // AYPageControlTests.m 3 | // AYPageControlTests 4 | // 5 | // Created by Andy on 16/3/28. 6 | // Copyright © 2016年 Andy. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface AYPageControlTests : XCTestCase 12 | 13 | @end 14 | 15 | @implementation AYPageControlTests 16 | 17 | - (void)setUp { 18 | [super setUp]; 19 | // Put setup code here. This method is called before the invocation of each test method in the class. 20 | } 21 | 22 | - (void)tearDown { 23 | // Put teardown code here. This method is called after the invocation of each test method in the class. 24 | [super tearDown]; 25 | } 26 | 27 | - (void)testExample { 28 | // This is an example of a functional test case. 29 | // Use XCTAssert and related functions to verify your tests produce the correct results. 30 | } 31 | 32 | - (void)testPerformanceExample { 33 | // This is an example of a performance test case. 34 | [self measureBlock:^{ 35 | // Put the code you want to measure the time of here. 36 | }]; 37 | } 38 | 39 | @end 40 | -------------------------------------------------------------------------------- /AYPageControlTests/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 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | 24 | 25 | -------------------------------------------------------------------------------- /AYPageControlUITests/AYPageControlUITests.m: -------------------------------------------------------------------------------- 1 | // 2 | // AYPageControlUITests.m 3 | // AYPageControlUITests 4 | // 5 | // Created by Andy on 16/3/28. 6 | // Copyright © 2016年 Andy. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface AYPageControlUITests : XCTestCase 12 | 13 | @end 14 | 15 | @implementation AYPageControlUITests 16 | 17 | - (void)setUp { 18 | [super setUp]; 19 | 20 | // Put setup code here. This method is called before the invocation of each test method in the class. 21 | 22 | // In UI tests it is usually best to stop immediately when a failure occurs. 23 | self.continueAfterFailure = NO; 24 | // UI tests must launch the application that they test. Doing this in setup will make sure it happens for each test method. 25 | [[[XCUIApplication alloc] init] launch]; 26 | 27 | // In UI tests it’s important to set the initial state - such as interface orientation - required for your tests before they run. The setUp method is a good place to do this. 28 | } 29 | 30 | - (void)tearDown { 31 | // Put teardown code here. This method is called after the invocation of each test method in the class. 32 | [super tearDown]; 33 | } 34 | 35 | - (void)testExample { 36 | // Use recording to get started writing UI tests. 37 | // Use XCTAssert and related functions to verify your tests produce the correct results. 38 | } 39 | 40 | @end 41 | -------------------------------------------------------------------------------- /AYPageControlUITests/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 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | 24 | 25 | -------------------------------------------------------------------------------- /License: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2016 黄鹏飞 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # AYPageControl 2 | [![LICENSE](https://img.shields.io/badge/license-MIT-green.svg)](https://github.com/AYJk/AYPageControl/blob/master/License)  3 | ![CocoaPods Version](https://img.shields.io/badge/pod-v0.0.2-brightgreen.svg) 4 | [![SUPPORT](https://img.shields.io/badge/support-iOS%207%2B%20-blue.svg)](https://en.wikipedia.org/wiki/IOS_7)  5 | [![BLOG](https://img.shields.io/badge/blog-ayjkdev.top-orange.svg)](http://ayjkdev.top/)  6 | 7 | 8 | 一个有动效的PageControl,效果图如下: 9 | 10 | ![效果图](http://7xrofo.com1.z0.glb.clouddn.com/version002.gif) 11 | 12 | ##我的blog中有相关的内容讲解 13 | [一个水滴动效的pageController(一)](http://ayjkdev.top/2016/03/25/ios-animation-circle-view/) 14 | 15 | ##如何使用 16 | ###1.导入头文件 17 | ```objc 18 | #import "AYPageControl.h" 19 | ``` 20 | ###2.为pageControl设置总页数并绑定scrollview 21 | ```objc 22 | // 设置总页数 23 | self.pageControlView.numberOfPages = totalPages; 24 | // 绑定对应的scrollview 25 | self.pageControlView.bindingScrollView = self.bannerScrollView; 26 | // 设置形变小球的颜色 27 | self.pageControlView.selectedColor = [UIColor blackColor]; 28 | // 设置背景小球的颜色 29 | self.pageControlView.unSelectedColor = [UIColor lightGrayColor]; 30 | ``` 31 | ###3.在代理方法中设置pageControl的属性 32 | ```objc 33 | // 将scrollview的contentOffset.x赋值给pageControl进行计算 34 | - (void)scrollViewDidScroll:(UIScrollView *)scrollView { 35 | 36 | self.pageControlView.contentOffset_x = scrollView.contentOffset.x; 37 | } 38 | // scrollview滑动玩后将最终的contentOffset传递过去 39 | - (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView { 40 | 41 | self.pageControlView.lastContentOffset_x = scrollView.contentOffset.x; 42 | } 43 | // scrollview滑动玩后将最终的contentOffset传递过去(暂时未用到,后期添加功能使用) 44 | - (void)scrollViewDidEndScrollingAnimation:(UIScrollView *)scrollView { 45 | 46 | self.pageControlView.lastContentOffset_x = scrollView.contentOffset.x; 47 | } 48 | ``` 49 | ##安装 50 | AYPageControl支持[CocoaPods](https://cocoapods.org/),在Podfile中输入 51 | ```objc 52 | pod 'AYPageControl' 53 | ``` 54 | 55 | ##更新内容 56 | ###v0.0.2 57 | 58 | * 优化了滑动视图时,小球的形变动画。 59 | 60 | ###v0.0.1 61 | 62 | * 首次提交:实现动画 63 | 64 | ##License 65 | This project is under MIT License. See LICENSE file for more information. 66 | --------------------------------------------------------------------------------