├── .DS_Store ├── README.md ├── RMPageControlDemo.xcodeproj ├── project.pbxproj ├── project.xcworkspace │ ├── contents.xcworkspacedata │ └── xcuserdata │ │ └── rupammitra.xcuserdatad │ │ └── UserInterfaceState.xcuserstate └── xcuserdata │ └── rupammitra.xcuserdatad │ ├── xcdebugger │ └── Breakpoints_v2.xcbkptlist │ └── xcschemes │ ├── RMPageControlDemo.xcscheme │ └── xcschememanagement.plist ├── RMPageControlDemo ├── .DS_Store ├── AppDelegate.swift ├── Assets.xcassets │ └── AppIcon.appiconset │ │ ├── Contents.json │ │ ├── Icon-60@2x.png │ │ ├── Icon-60@3x.png │ │ ├── Icon-Small-40@2x.png │ │ ├── Icon-Small-40@3x.png │ │ ├── Icon-Small@2x.png │ │ └── Icon-Small@3x.png ├── Base.lproj │ ├── LaunchScreen.storyboard │ └── Main.storyboard ├── Info.plist └── ViewController.swift ├── RMShapesPageControl.swift └── Screenshots ├── .DS_Store ├── Inspectables.png ├── RMSquarePageControl.gif └── Shapes.png /.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rupammitra/RMShapesPageControl/9d876669ba1a777e0a34ec1472f799765cce21d8/.DS_Store -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # RMShapesPageControl 2 | 3 | ![alt tag](https://github.com/rupammitra/RMShapesPageControl/blob/master/Screenshots/Shapes.png)![alt tag](https://github.com/rupammitra/RMSquarePageControl/blob/master/Screenshots/RMSquarePageControl.gif) 4 | 5 | ## Usage 6 | 7 | 1. Drag and drop the RMShapesPageControl.swift into your project. 8 | 2. Take a view in storyboard and assign the class as RMShapesPageControl in identity inspector. 9 | 3. Set the inspectables in attributes inspector and all done. 10 | 4. Number of pages can be set dynamically from code even as per requirement. 11 | 12 | ### Indicator Configuration 13 | 1. Square 14 | 2. Circle 15 | 3. Triangle in Positive direction 16 | 4. Triangle in Negative direction 17 | 18 | #### Note 19 | 20 | 1. Vertical Configuration: Make the view width narrower and the height lengthier. 21 | 2. Horizontal Configuration: Make the view width lengthier and the height narrower. 22 | 23 | ![alt tag](https://github.com/rupammitra/RMSquarePageControl/blob/master/Screenshots/Inspectables.png) 24 | -------------------------------------------------------------------------------- /RMPageControlDemo.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | FCE934911D68BD8600824DBE /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = FCE934901D68BD8600824DBE /* AppDelegate.swift */; }; 11 | FCE934931D68BD8600824DBE /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = FCE934921D68BD8600824DBE /* ViewController.swift */; }; 12 | FCE934961D68BD8600824DBE /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = FCE934941D68BD8600824DBE /* Main.storyboard */; }; 13 | FCE934981D68BD8600824DBE /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = FCE934971D68BD8600824DBE /* Assets.xcassets */; }; 14 | FCE9349B1D68BD8600824DBE /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = FCE934991D68BD8600824DBE /* LaunchScreen.storyboard */; }; 15 | FCE934A71D68E5C900824DBE /* RMShapesPageControl.swift in Sources */ = {isa = PBXBuildFile; fileRef = FCE934A61D68E5C900824DBE /* RMShapesPageControl.swift */; }; 16 | /* End PBXBuildFile section */ 17 | 18 | /* Begin PBXFileReference section */ 19 | FCE9348D1D68BD8600824DBE /* RMPageControlDemo.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = RMPageControlDemo.app; sourceTree = BUILT_PRODUCTS_DIR; }; 20 | FCE934901D68BD8600824DBE /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 21 | FCE934921D68BD8600824DBE /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = ""; }; 22 | FCE934951D68BD8600824DBE /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 23 | FCE934971D68BD8600824DBE /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 24 | FCE9349A1D68BD8600824DBE /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 25 | FCE9349C1D68BD8600824DBE /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 26 | FCE934A61D68E5C900824DBE /* RMShapesPageControl.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RMShapesPageControl.swift; sourceTree = ""; }; 27 | /* End PBXFileReference section */ 28 | 29 | /* Begin PBXFrameworksBuildPhase section */ 30 | FCE9348A1D68BD8600824DBE /* Frameworks */ = { 31 | isa = PBXFrameworksBuildPhase; 32 | buildActionMask = 2147483647; 33 | files = ( 34 | ); 35 | runOnlyForDeploymentPostprocessing = 0; 36 | }; 37 | /* End PBXFrameworksBuildPhase section */ 38 | 39 | /* Begin PBXGroup section */ 40 | FCE934841D68BD8600824DBE = { 41 | isa = PBXGroup; 42 | children = ( 43 | FCE934A61D68E5C900824DBE /* RMShapesPageControl.swift */, 44 | FCE9348F1D68BD8600824DBE /* RMPageControlDemo */, 45 | FCE9348E1D68BD8600824DBE /* Products */, 46 | ); 47 | sourceTree = ""; 48 | }; 49 | FCE9348E1D68BD8600824DBE /* Products */ = { 50 | isa = PBXGroup; 51 | children = ( 52 | FCE9348D1D68BD8600824DBE /* RMPageControlDemo.app */, 53 | ); 54 | name = Products; 55 | sourceTree = ""; 56 | }; 57 | FCE9348F1D68BD8600824DBE /* RMPageControlDemo */ = { 58 | isa = PBXGroup; 59 | children = ( 60 | FCE934901D68BD8600824DBE /* AppDelegate.swift */, 61 | FCE934921D68BD8600824DBE /* ViewController.swift */, 62 | FCE934941D68BD8600824DBE /* Main.storyboard */, 63 | FCE934971D68BD8600824DBE /* Assets.xcassets */, 64 | FCE934991D68BD8600824DBE /* LaunchScreen.storyboard */, 65 | FCE9349C1D68BD8600824DBE /* Info.plist */, 66 | ); 67 | path = RMPageControlDemo; 68 | sourceTree = ""; 69 | }; 70 | /* End PBXGroup section */ 71 | 72 | /* Begin PBXNativeTarget section */ 73 | FCE9348C1D68BD8600824DBE /* RMPageControlDemo */ = { 74 | isa = PBXNativeTarget; 75 | buildConfigurationList = FCE9349F1D68BD8600824DBE /* Build configuration list for PBXNativeTarget "RMPageControlDemo" */; 76 | buildPhases = ( 77 | FCE934891D68BD8600824DBE /* Sources */, 78 | FCE9348A1D68BD8600824DBE /* Frameworks */, 79 | FCE9348B1D68BD8600824DBE /* Resources */, 80 | ); 81 | buildRules = ( 82 | ); 83 | dependencies = ( 84 | ); 85 | name = RMPageControlDemo; 86 | productName = RMPageControlDemo; 87 | productReference = FCE9348D1D68BD8600824DBE /* RMPageControlDemo.app */; 88 | productType = "com.apple.product-type.application"; 89 | }; 90 | /* End PBXNativeTarget section */ 91 | 92 | /* Begin PBXProject section */ 93 | FCE934851D68BD8600824DBE /* Project object */ = { 94 | isa = PBXProject; 95 | attributes = { 96 | LastSwiftUpdateCheck = 0730; 97 | LastUpgradeCheck = 0830; 98 | ORGANIZATIONNAME = "Rupam Mitra"; 99 | TargetAttributes = { 100 | FCE9348C1D68BD8600824DBE = { 101 | CreatedOnToolsVersion = 7.3.1; 102 | LastSwiftMigration = 0800; 103 | }; 104 | }; 105 | }; 106 | buildConfigurationList = FCE934881D68BD8600824DBE /* Build configuration list for PBXProject "RMPageControlDemo" */; 107 | compatibilityVersion = "Xcode 3.2"; 108 | developmentRegion = English; 109 | hasScannedForEncodings = 0; 110 | knownRegions = ( 111 | en, 112 | Base, 113 | ); 114 | mainGroup = FCE934841D68BD8600824DBE; 115 | productRefGroup = FCE9348E1D68BD8600824DBE /* Products */; 116 | projectDirPath = ""; 117 | projectRoot = ""; 118 | targets = ( 119 | FCE9348C1D68BD8600824DBE /* RMPageControlDemo */, 120 | ); 121 | }; 122 | /* End PBXProject section */ 123 | 124 | /* Begin PBXResourcesBuildPhase section */ 125 | FCE9348B1D68BD8600824DBE /* Resources */ = { 126 | isa = PBXResourcesBuildPhase; 127 | buildActionMask = 2147483647; 128 | files = ( 129 | FCE9349B1D68BD8600824DBE /* LaunchScreen.storyboard in Resources */, 130 | FCE934981D68BD8600824DBE /* Assets.xcassets in Resources */, 131 | FCE934961D68BD8600824DBE /* Main.storyboard in Resources */, 132 | ); 133 | runOnlyForDeploymentPostprocessing = 0; 134 | }; 135 | /* End PBXResourcesBuildPhase section */ 136 | 137 | /* Begin PBXSourcesBuildPhase section */ 138 | FCE934891D68BD8600824DBE /* Sources */ = { 139 | isa = PBXSourcesBuildPhase; 140 | buildActionMask = 2147483647; 141 | files = ( 142 | FCE934931D68BD8600824DBE /* ViewController.swift in Sources */, 143 | FCE934A71D68E5C900824DBE /* RMShapesPageControl.swift in Sources */, 144 | FCE934911D68BD8600824DBE /* AppDelegate.swift in Sources */, 145 | ); 146 | runOnlyForDeploymentPostprocessing = 0; 147 | }; 148 | /* End PBXSourcesBuildPhase section */ 149 | 150 | /* Begin PBXVariantGroup section */ 151 | FCE934941D68BD8600824DBE /* Main.storyboard */ = { 152 | isa = PBXVariantGroup; 153 | children = ( 154 | FCE934951D68BD8600824DBE /* Base */, 155 | ); 156 | name = Main.storyboard; 157 | sourceTree = ""; 158 | }; 159 | FCE934991D68BD8600824DBE /* LaunchScreen.storyboard */ = { 160 | isa = PBXVariantGroup; 161 | children = ( 162 | FCE9349A1D68BD8600824DBE /* Base */, 163 | ); 164 | name = LaunchScreen.storyboard; 165 | sourceTree = ""; 166 | }; 167 | /* End PBXVariantGroup section */ 168 | 169 | /* Begin XCBuildConfiguration section */ 170 | FCE9349D1D68BD8600824DBE /* Debug */ = { 171 | isa = XCBuildConfiguration; 172 | buildSettings = { 173 | ALWAYS_SEARCH_USER_PATHS = NO; 174 | CLANG_ANALYZER_NONNULL = YES; 175 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 176 | CLANG_CXX_LIBRARY = "libc++"; 177 | CLANG_ENABLE_MODULES = YES; 178 | CLANG_ENABLE_OBJC_ARC = YES; 179 | CLANG_WARN_BOOL_CONVERSION = YES; 180 | CLANG_WARN_CONSTANT_CONVERSION = YES; 181 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 182 | CLANG_WARN_EMPTY_BODY = YES; 183 | CLANG_WARN_ENUM_CONVERSION = YES; 184 | CLANG_WARN_INFINITE_RECURSION = YES; 185 | CLANG_WARN_INT_CONVERSION = YES; 186 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 187 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 188 | CLANG_WARN_UNREACHABLE_CODE = YES; 189 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 190 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 191 | COPY_PHASE_STRIP = NO; 192 | DEBUG_INFORMATION_FORMAT = dwarf; 193 | ENABLE_STRICT_OBJC_MSGSEND = YES; 194 | ENABLE_TESTABILITY = YES; 195 | GCC_C_LANGUAGE_STANDARD = gnu99; 196 | GCC_DYNAMIC_NO_PIC = NO; 197 | GCC_NO_COMMON_BLOCKS = YES; 198 | GCC_OPTIMIZATION_LEVEL = 0; 199 | GCC_PREPROCESSOR_DEFINITIONS = ( 200 | "DEBUG=1", 201 | "$(inherited)", 202 | ); 203 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 204 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 205 | GCC_WARN_UNDECLARED_SELECTOR = YES; 206 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 207 | GCC_WARN_UNUSED_FUNCTION = YES; 208 | GCC_WARN_UNUSED_VARIABLE = YES; 209 | IPHONEOS_DEPLOYMENT_TARGET = 9.3; 210 | MTL_ENABLE_DEBUG_INFO = YES; 211 | ONLY_ACTIVE_ARCH = YES; 212 | SDKROOT = iphoneos; 213 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 214 | }; 215 | name = Debug; 216 | }; 217 | FCE9349E1D68BD8600824DBE /* Release */ = { 218 | isa = XCBuildConfiguration; 219 | buildSettings = { 220 | ALWAYS_SEARCH_USER_PATHS = NO; 221 | CLANG_ANALYZER_NONNULL = YES; 222 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 223 | CLANG_CXX_LIBRARY = "libc++"; 224 | CLANG_ENABLE_MODULES = YES; 225 | CLANG_ENABLE_OBJC_ARC = YES; 226 | CLANG_WARN_BOOL_CONVERSION = YES; 227 | CLANG_WARN_CONSTANT_CONVERSION = YES; 228 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 229 | CLANG_WARN_EMPTY_BODY = YES; 230 | CLANG_WARN_ENUM_CONVERSION = YES; 231 | CLANG_WARN_INFINITE_RECURSION = YES; 232 | CLANG_WARN_INT_CONVERSION = YES; 233 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 234 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 235 | CLANG_WARN_UNREACHABLE_CODE = YES; 236 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 237 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 238 | COPY_PHASE_STRIP = NO; 239 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 240 | ENABLE_NS_ASSERTIONS = NO; 241 | ENABLE_STRICT_OBJC_MSGSEND = YES; 242 | GCC_C_LANGUAGE_STANDARD = gnu99; 243 | GCC_NO_COMMON_BLOCKS = YES; 244 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 245 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 246 | GCC_WARN_UNDECLARED_SELECTOR = YES; 247 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 248 | GCC_WARN_UNUSED_FUNCTION = YES; 249 | GCC_WARN_UNUSED_VARIABLE = YES; 250 | IPHONEOS_DEPLOYMENT_TARGET = 9.3; 251 | MTL_ENABLE_DEBUG_INFO = NO; 252 | SDKROOT = iphoneos; 253 | SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; 254 | VALIDATE_PRODUCT = YES; 255 | }; 256 | name = Release; 257 | }; 258 | FCE934A01D68BD8600824DBE /* Debug */ = { 259 | isa = XCBuildConfiguration; 260 | buildSettings = { 261 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 262 | INFOPLIST_FILE = RMPageControlDemo/Info.plist; 263 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 264 | PRODUCT_BUNDLE_IDENTIFIER = com.rupammitra.RMPageControlDemo; 265 | PRODUCT_NAME = "$(TARGET_NAME)"; 266 | SWIFT_VERSION = 3.0; 267 | }; 268 | name = Debug; 269 | }; 270 | FCE934A11D68BD8600824DBE /* Release */ = { 271 | isa = XCBuildConfiguration; 272 | buildSettings = { 273 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 274 | INFOPLIST_FILE = RMPageControlDemo/Info.plist; 275 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 276 | PRODUCT_BUNDLE_IDENTIFIER = com.rupammitra.RMPageControlDemo; 277 | PRODUCT_NAME = "$(TARGET_NAME)"; 278 | SWIFT_VERSION = 3.0; 279 | }; 280 | name = Release; 281 | }; 282 | /* End XCBuildConfiguration section */ 283 | 284 | /* Begin XCConfigurationList section */ 285 | FCE934881D68BD8600824DBE /* Build configuration list for PBXProject "RMPageControlDemo" */ = { 286 | isa = XCConfigurationList; 287 | buildConfigurations = ( 288 | FCE9349D1D68BD8600824DBE /* Debug */, 289 | FCE9349E1D68BD8600824DBE /* Release */, 290 | ); 291 | defaultConfigurationIsVisible = 0; 292 | defaultConfigurationName = Release; 293 | }; 294 | FCE9349F1D68BD8600824DBE /* Build configuration list for PBXNativeTarget "RMPageControlDemo" */ = { 295 | isa = XCConfigurationList; 296 | buildConfigurations = ( 297 | FCE934A01D68BD8600824DBE /* Debug */, 298 | FCE934A11D68BD8600824DBE /* Release */, 299 | ); 300 | defaultConfigurationIsVisible = 0; 301 | defaultConfigurationName = Release; 302 | }; 303 | /* End XCConfigurationList section */ 304 | }; 305 | rootObject = FCE934851D68BD8600824DBE /* Project object */; 306 | } 307 | -------------------------------------------------------------------------------- /RMPageControlDemo.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /RMPageControlDemo.xcodeproj/project.xcworkspace/xcuserdata/rupammitra.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rupammitra/RMShapesPageControl/9d876669ba1a777e0a34ec1472f799765cce21d8/RMPageControlDemo.xcodeproj/project.xcworkspace/xcuserdata/rupammitra.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /RMPageControlDemo.xcodeproj/xcuserdata/rupammitra.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | -------------------------------------------------------------------------------- /RMPageControlDemo.xcodeproj/xcuserdata/rupammitra.xcuserdatad/xcschemes/RMPageControlDemo.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 32 | 33 | 39 | 40 | 41 | 42 | 43 | 44 | 54 | 56 | 62 | 63 | 64 | 65 | 66 | 67 | 73 | 75 | 81 | 82 | 83 | 84 | 86 | 87 | 90 | 91 | 92 | -------------------------------------------------------------------------------- /RMPageControlDemo.xcodeproj/xcuserdata/rupammitra.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | RMPageControlDemo.xcscheme 8 | 9 | orderHint 10 | 0 11 | 12 | 13 | SuppressBuildableAutocreation 14 | 15 | FCE9348C1D68BD8600824DBE 16 | 17 | primary 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /RMPageControlDemo/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rupammitra/RMShapesPageControl/9d876669ba1a777e0a34ec1472f799765cce21d8/RMPageControlDemo/.DS_Store -------------------------------------------------------------------------------- /RMPageControlDemo/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.swift 3 | // RMPageControlDemo 4 | // 5 | // Created by Rupam Mitra on 20/08/16. 6 | // Copyright © 2016 Rupam Mitra. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | @UIApplicationMain 12 | class AppDelegate: UIResponder, UIApplicationDelegate { 13 | 14 | var window: UIWindow? 15 | 16 | 17 | func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool { 18 | // Override point for customization after application launch. 19 | return true 20 | } 21 | 22 | func applicationWillResignActive(_ application: UIApplication) { 23 | // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. 24 | // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game. 25 | } 26 | 27 | func applicationDidEnterBackground(_ application: UIApplication) { 28 | // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. 29 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 30 | } 31 | 32 | func applicationWillEnterForeground(_ application: UIApplication) { 33 | // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background. 34 | } 35 | 36 | func applicationDidBecomeActive(_ application: UIApplication) { 37 | // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. 38 | } 39 | 40 | func applicationWillTerminate(_ application: UIApplication) { 41 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 42 | } 43 | 44 | 45 | } 46 | 47 | -------------------------------------------------------------------------------- /RMPageControlDemo/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "size" : "29x29", 5 | "idiom" : "iphone", 6 | "filename" : "Icon-Small@2x.png", 7 | "scale" : "2x" 8 | }, 9 | { 10 | "size" : "29x29", 11 | "idiom" : "iphone", 12 | "filename" : "Icon-Small@3x.png", 13 | "scale" : "3x" 14 | }, 15 | { 16 | "size" : "40x40", 17 | "idiom" : "iphone", 18 | "filename" : "Icon-Small-40@2x.png", 19 | "scale" : "2x" 20 | }, 21 | { 22 | "size" : "40x40", 23 | "idiom" : "iphone", 24 | "filename" : "Icon-Small-40@3x.png", 25 | "scale" : "3x" 26 | }, 27 | { 28 | "size" : "60x60", 29 | "idiom" : "iphone", 30 | "filename" : "Icon-60@2x.png", 31 | "scale" : "2x" 32 | }, 33 | { 34 | "size" : "60x60", 35 | "idiom" : "iphone", 36 | "filename" : "Icon-60@3x.png", 37 | "scale" : "3x" 38 | } 39 | ], 40 | "info" : { 41 | "version" : 1, 42 | "author" : "xcode" 43 | } 44 | } -------------------------------------------------------------------------------- /RMPageControlDemo/Assets.xcassets/AppIcon.appiconset/Icon-60@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rupammitra/RMShapesPageControl/9d876669ba1a777e0a34ec1472f799765cce21d8/RMPageControlDemo/Assets.xcassets/AppIcon.appiconset/Icon-60@2x.png -------------------------------------------------------------------------------- /RMPageControlDemo/Assets.xcassets/AppIcon.appiconset/Icon-60@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rupammitra/RMShapesPageControl/9d876669ba1a777e0a34ec1472f799765cce21d8/RMPageControlDemo/Assets.xcassets/AppIcon.appiconset/Icon-60@3x.png -------------------------------------------------------------------------------- /RMPageControlDemo/Assets.xcassets/AppIcon.appiconset/Icon-Small-40@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rupammitra/RMShapesPageControl/9d876669ba1a777e0a34ec1472f799765cce21d8/RMPageControlDemo/Assets.xcassets/AppIcon.appiconset/Icon-Small-40@2x.png -------------------------------------------------------------------------------- /RMPageControlDemo/Assets.xcassets/AppIcon.appiconset/Icon-Small-40@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rupammitra/RMShapesPageControl/9d876669ba1a777e0a34ec1472f799765cce21d8/RMPageControlDemo/Assets.xcassets/AppIcon.appiconset/Icon-Small-40@3x.png -------------------------------------------------------------------------------- /RMPageControlDemo/Assets.xcassets/AppIcon.appiconset/Icon-Small@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rupammitra/RMShapesPageControl/9d876669ba1a777e0a34ec1472f799765cce21d8/RMPageControlDemo/Assets.xcassets/AppIcon.appiconset/Icon-Small@2x.png -------------------------------------------------------------------------------- /RMPageControlDemo/Assets.xcassets/AppIcon.appiconset/Icon-Small@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rupammitra/RMShapesPageControl/9d876669ba1a777e0a34ec1472f799765cce21d8/RMPageControlDemo/Assets.xcassets/AppIcon.appiconset/Icon-Small@3x.png -------------------------------------------------------------------------------- /RMPageControlDemo/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 | 34 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | -------------------------------------------------------------------------------- /RMPageControlDemo/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 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | 173 | 174 | 175 | 176 | 177 | 178 | 179 | 180 | 181 | 182 | 183 | 184 | 185 | 186 | 187 | 188 | 189 | 190 | 191 | 192 | 193 | 194 | 195 | 196 | 197 | 198 | 199 | 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207 | 208 | 209 | 210 | 211 | 212 | 213 | 214 | 215 | 216 | 217 | 218 | 219 | 220 | 221 | 222 | 223 | 224 | 225 | 226 | 227 | 228 | 229 | 230 | 231 | 232 | 233 | 234 | 235 | 236 | 237 | 238 | 239 | 240 | 241 | 242 | 243 | 244 | 245 | 246 | -------------------------------------------------------------------------------- /RMPageControlDemo/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 | UIInterfaceOrientationPortraitUpsideDown 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /RMPageControlDemo/ViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.swift 3 | // RMPageControlDemo 4 | // 5 | // Created by Rupam Mitra on 20/08/16. 6 | // Copyright © 2016 Rupam Mitra. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | class ViewController: UIViewController { 12 | 13 | @IBOutlet weak var pageCollectionView: UICollectionView! 14 | 15 | @IBOutlet var squarePageControl: RMShapesPageControl! 16 | @IBOutlet var circlePageControl: RMShapesPageControl! 17 | @IBOutlet var trianglePositivePageControl: RMShapesPageControl! 18 | @IBOutlet var triangleNegativePageControl: RMShapesPageControl! 19 | 20 | override func viewDidLoad() { 21 | super.viewDidLoad() 22 | // Do any additional setup after loading the view, typically from a nib. 23 | 24 | squarePageControl.numberOfPages = pageCollectionView.numberOfItems(inSection: 0) 25 | circlePageControl.numberOfPages = pageCollectionView.numberOfItems(inSection: 0) 26 | trianglePositivePageControl.numberOfPages = pageCollectionView.numberOfItems(inSection: 0) 27 | triangleNegativePageControl.numberOfPages = pageCollectionView.numberOfItems(inSection: 0) 28 | } 29 | 30 | override func didReceiveMemoryWarning() { 31 | super.didReceiveMemoryWarning() 32 | // Dispose of any resources that can be recreated. 33 | } 34 | } 35 | 36 | extension ViewController: UICollectionViewDataSource { 37 | 38 | func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int { 39 | return 10 40 | } 41 | 42 | func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell { 43 | 44 | let cell = collectionView.dequeueReusableCell(withReuseIdentifier: String(describing: UICollectionViewCell.self), for: indexPath) 45 | cell.backgroundColor = UIColor.randomColor() 46 | return cell 47 | } 48 | } 49 | 50 | extension ViewController: UICollectionViewDelegate { 51 | 52 | func scrollViewDidEndDecelerating(_ scrollView: UIScrollView) { 53 | 54 | let page = scrollView.contentOffset.x / scrollView.frame.width 55 | squarePageControl.currentPage = Int(page) 56 | circlePageControl.currentPage = Int(page) 57 | trianglePositivePageControl.currentPage = Int(page) 58 | triangleNegativePageControl.currentPage = Int(page) 59 | } 60 | } 61 | 62 | extension UIColor { 63 | 64 | static func randomColor() -> UIColor? { 65 | 66 | let randomRed: CGFloat = CGFloat(drand48()) 67 | let randomGreen: CGFloat = CGFloat(drand48()) 68 | let randomBlue: CGFloat = CGFloat(drand48()) 69 | return UIColor(red: randomRed, green: randomGreen, blue: randomBlue, alpha: 1.0) 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /RMShapesPageControl.swift: -------------------------------------------------------------------------------- 1 | // 2 | // RMSquarePageControl.swift 3 | // SquarePageControl 4 | // 5 | // Created by Rupam Mitra on 20/08/16. 6 | // Copyright (c) 2016 Rupam Mitra. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | enum Direction: Int { 12 | case positive = 1 13 | case negative = 2 14 | } 15 | 16 | enum IndicatorType: Int { 17 | case square = 1 18 | case circle = 2 19 | case triangle = 3 20 | } 21 | 22 | @IBDesignable 23 | class RMShapesPageControl: UIControl { 24 | 25 | fileprivate let kDotLength: CGFloat = 4.0 26 | fileprivate let kDotSpace: CGFloat = 12.0 27 | 28 | override init(frame: CGRect) { 29 | super.init(frame: frame) 30 | self.backgroundColor = UIColor.clear 31 | } 32 | 33 | required init(coder aDecoder: NSCoder) { 34 | super.init(coder: aDecoder)! 35 | self.backgroundColor = UIColor.clear 36 | } 37 | 38 | var indicatorType: IndicatorType = .square { 39 | didSet { 40 | setNeedsDisplay() 41 | } 42 | } 43 | 44 | @IBInspectable var indicator: Int = 1 { 45 | didSet { 46 | indicatorType = IndicatorType(rawValue: indicator)! 47 | } 48 | } 49 | 50 | var direction: Direction = .positive { 51 | didSet { 52 | setNeedsDisplay() 53 | } 54 | } 55 | 56 | @IBInspectable var directionable: Int = 1 { 57 | didSet { 58 | direction = Direction(rawValue: directionable)! 59 | } 60 | } 61 | 62 | @IBInspectable var numberOfPages: Int = 0 { 63 | didSet { 64 | let center = self.center 65 | self.center = center 66 | self.currentPage = min(max(0, self.currentPage), numberOfPages - 1) 67 | self.setNeedsDisplay() 68 | if hidesForSinglePage == true && numberOfPages < 2 { 69 | self.isHidden = true 70 | }else { 71 | self.isHidden = false 72 | } 73 | } 74 | } 75 | 76 | @IBInspectable var currentPage: Int = 0 { 77 | willSet { 78 | if currentPage == newValue { 79 | return 80 | } 81 | } 82 | didSet { 83 | currentPage = min(max(0, currentPage), numberOfPages - 1) 84 | if defersCurrentPageDisplay == false { 85 | setNeedsDisplay() 86 | } 87 | } 88 | } 89 | 90 | @IBInspectable var hidesForSinglePage: Bool = false { 91 | didSet { 92 | if hidesForSinglePage == true && numberOfPages < 2 { 93 | isHidden = true 94 | } 95 | } 96 | } 97 | 98 | var defersCurrentPageDisplay: Bool = false 99 | 100 | @IBInspectable var currentPageColor: UIColor? { 101 | didSet { 102 | setNeedsDisplay() 103 | } 104 | } 105 | 106 | @IBInspectable var otherPagesColor: UIColor? { 107 | didSet { 108 | setNeedsDisplay() 109 | } 110 | } 111 | 112 | @IBInspectable var indicatorLength: CGFloat = 4.0 { 113 | didSet { 114 | setNeedsDisplay() 115 | } 116 | } 117 | 118 | @IBInspectable var indicatorSpace: CGFloat = 12.0 { 119 | didSet { 120 | setNeedsDisplay() 121 | } 122 | } 123 | 124 | // Only override drawRect: if you perform custom drawing. 125 | // An empty implementation adversely affects performance during animation. 126 | final override func draw(_ rect: CGRect) { 127 | super.draw(rect) 128 | // Drawing code 129 | let context: CGContext = UIGraphicsGetCurrentContext()! 130 | 131 | context.saveGState() 132 | context.setAllowsAntialiasing(true) 133 | 134 | let length = (indicatorLength > 0) ? indicatorLength : kDotLength 135 | let space = (indicatorSpace > 0) ? indicatorSpace : kDotSpace 136 | 137 | let currentBounds = bounds 138 | let dotsWidth = CGFloat(numberOfPages) * length + CGFloat(max(0, numberOfPages - 1)) * space 139 | 140 | var x: CGFloat = 0.0 141 | var y: CGFloat = 0.0 142 | 143 | if frame.height > frame.width { 144 | x = currentBounds.midX - length / 2 145 | y = currentBounds.midY - dotsWidth / 2 146 | }else { 147 | x = currentBounds.midX - dotsWidth / 2 148 | y = currentBounds.midY - length / 2 149 | } 150 | 151 | let drawOnColor: UIColor = (currentPageColor != nil) ? currentPageColor! : UIColor(white: 1.0, alpha: 1.0) 152 | let drawOffColor: UIColor = (otherPagesColor != nil) ? otherPagesColor! : UIColor(white: 0.7, alpha: 0.5) 153 | 154 | for i in 0 ..< numberOfPages { 155 | 156 | let dotRect: CGRect = CGRect(x: x, y: y, width: length, height: length) 157 | 158 | if i == self.currentPage { 159 | context.setFillColor(drawOnColor.cgColor) 160 | createShapes(inContext: context, forDotRect: dotRect) 161 | }else{ 162 | context.setFillColor(drawOffColor.cgColor) 163 | createShapes(inContext: context, forDotRect: dotRect) 164 | } 165 | 166 | if self.frame.height > self.frame.width { 167 | y += length + space 168 | }else { 169 | x += length + space 170 | } 171 | } 172 | 173 | // restore the context 174 | context.restoreGState() 175 | } 176 | 177 | func createShapes(inContext context: CGContext, forDotRect dotRect: CGRect) { 178 | switch indicatorType { 179 | case .square: 180 | context.fill(dotRect) 181 | case .circle: 182 | context.fillEllipse(in: dotRect) 183 | case .triangle: 184 | createTriangle(drawRect: dotRect, inDirection: direction) 185 | } 186 | } 187 | 188 | func createTriangle(drawRect: CGRect, inDirection direction: Direction) { 189 | let trianglePath = UIBezierPath() 190 | if self.frame.height > self.frame.width { 191 | trianglePath.move(to: CGPoint(x: drawRect.midX, y:drawRect.minY)) 192 | trianglePath.addLine(to: CGPoint(x:direction == .positive ? drawRect.maxX : drawRect.minX, y:drawRect.midY)) 193 | trianglePath.addLine(to: CGPoint(x:drawRect.midX, y:drawRect.maxY)) 194 | }else { 195 | trianglePath.move(to: CGPoint(x: drawRect.minX, y:drawRect.midY)) 196 | trianglePath.addLine(to: CGPoint(x:drawRect.midX, y:direction == .positive ? drawRect.minY : drawRect.maxY)) 197 | trianglePath.addLine(to: CGPoint(x:drawRect.maxX, y:drawRect.midY)) 198 | } 199 | trianglePath.fill() 200 | } 201 | 202 | fileprivate func updateCurrentPageDisplay() { 203 | if defersCurrentPageDisplay == false { 204 | return 205 | } 206 | setNeedsDisplay() 207 | } 208 | 209 | fileprivate func sizeForNumberOfPages(_ pageCount: NSInteger) -> CGSize { 210 | 211 | let length: CGFloat = (indicatorLength > 0) ? indicatorLength : kDotLength 212 | let space: CGFloat = (indicatorSpace > 0) ? indicatorSpace : kDotSpace 213 | return CGSize(width: max(44.0, length + 4.0), height: CGFloat(pageCount) * length + CGFloat((pageCount - 1)) * space + 44.0) 214 | } 215 | } 216 | -------------------------------------------------------------------------------- /Screenshots/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rupammitra/RMShapesPageControl/9d876669ba1a777e0a34ec1472f799765cce21d8/Screenshots/.DS_Store -------------------------------------------------------------------------------- /Screenshots/Inspectables.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rupammitra/RMShapesPageControl/9d876669ba1a777e0a34ec1472f799765cce21d8/Screenshots/Inspectables.png -------------------------------------------------------------------------------- /Screenshots/RMSquarePageControl.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rupammitra/RMShapesPageControl/9d876669ba1a777e0a34ec1472f799765cce21d8/Screenshots/RMSquarePageControl.gif -------------------------------------------------------------------------------- /Screenshots/Shapes.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rupammitra/RMShapesPageControl/9d876669ba1a777e0a34ec1472f799765cce21d8/Screenshots/Shapes.png --------------------------------------------------------------------------------