├── .gitignore ├── .swiftlint.yml ├── .travis.yml ├── Demo.gif ├── Example ├── Example.xcodeproj │ ├── project.pbxproj │ └── project.xcworkspace │ │ └── contents.xcworkspacedata └── Example │ ├── AppDelegate.swift │ ├── Assets.xcassets │ └── AppIcon.appiconset │ │ └── Contents.json │ ├── Base.lproj │ └── MainMenu.xib │ └── Info.plist ├── LICENSE ├── NSPageControl.podspec ├── NSPageControl.xcodeproj ├── project.pbxproj ├── project.xcworkspace │ └── contents.xcworkspacedata └── xcshareddata │ └── xcschemes │ └── NSPageControl.xcscheme ├── NSPageControl ├── Info.plist └── NSPageControl.swift ├── NSPageControlTests ├── Info.plist └── NSPageControlTests.swift └── README.md /.gitignore: -------------------------------------------------------------------------------- 1 | ### https://raw.github.com/github/gitignore/66f6232221f70a17a3c37feb3fcb77da850e149c/Swift.gitignore 2 | 3 | # Xcode 4 | # 5 | # gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore 6 | 7 | ## Build generated 8 | build/ 9 | DerivedData/ 10 | 11 | ## Various settings 12 | *.pbxuser 13 | !default.pbxuser 14 | *.mode1v3 15 | !default.mode1v3 16 | *.mode2v3 17 | !default.mode2v3 18 | *.perspectivev3 19 | !default.perspectivev3 20 | xcuserdata/ 21 | 22 | ## Other 23 | *.moved-aside 24 | *.xcuserstate 25 | 26 | ## Obj-C/Swift specific 27 | *.hmap 28 | *.ipa 29 | 30 | ## Playgrounds 31 | timeline.xctimeline 32 | playground.xcworkspace 33 | 34 | # Swift Package Manager 35 | # 36 | # Add this line if you want to avoid checking in source code from Swift Package Manager dependencies. 37 | # Packages/ 38 | .build/ 39 | 40 | # CocoaPods 41 | # 42 | # We recommend against adding the Pods directory to your .gitignore. However 43 | # you should judge for yourself, the pros and cons are mentioned at: 44 | # https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control 45 | # 46 | # Pods/ 47 | 48 | # Carthage 49 | # 50 | # Add this line if you want to avoid checking in source code from Carthage dependencies. 51 | # Carthage/Checkouts 52 | 53 | Carthage/Build 54 | 55 | # fastlane 56 | # 57 | # It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the 58 | # screenshots whenever they are needed. 59 | # For more information about the recommended setup visit: 60 | # https://github.com/fastlane/fastlane/blob/master/docs/Gitignore.md 61 | 62 | fastlane/report.xml 63 | fastlane/Preview.html 64 | fastlane/screenshots 65 | fastlane/test_output 66 | 67 | 68 | -------------------------------------------------------------------------------- /.swiftlint.yml: -------------------------------------------------------------------------------- 1 | line_length: 150 2 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: 2 | objective-c 3 | osx_image: 4 | xcode8 5 | xcode_project: 6 | NSPageControl.xcodeproj 7 | xcode_scheme: 8 | NSPageControl 9 | script: 10 | - xcodebuild -project NSPageControl.xcodeproj -scheme NSPageControl clean build CODE_SIGN_IDENTITY="" CODE_SIGNING_REQUIRED=NO | xcpretty 11 | -------------------------------------------------------------------------------- /Demo.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nerd0geek1/NSPageControl/b90eebfa7da5d75d4256de0f5b67ac92b0398fca/Demo.gif -------------------------------------------------------------------------------- /Example/Example.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 736851171CA544A200E2FEA0 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 736851161CA544A200E2FEA0 /* AppDelegate.swift */; }; 11 | 736851191CA544A200E2FEA0 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 736851181CA544A200E2FEA0 /* Assets.xcassets */; }; 12 | 7368511C1CA544A200E2FEA0 /* MainMenu.xib in Resources */ = {isa = PBXBuildFile; fileRef = 7368511A1CA544A200E2FEA0 /* MainMenu.xib */; }; 13 | 736851461CA57BCD00E2FEA0 /* NSPageControl.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 736851451CA57BCD00E2FEA0 /* NSPageControl.framework */; }; 14 | 736851481CA57BD200E2FEA0 /* NSPageControl.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 736851451CA57BCD00E2FEA0 /* NSPageControl.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; 15 | /* End PBXBuildFile section */ 16 | 17 | /* Begin PBXCopyFilesBuildPhase section */ 18 | 736851351CA5534E00E2FEA0 /* Embed Frameworks */ = { 19 | isa = PBXCopyFilesBuildPhase; 20 | buildActionMask = 2147483647; 21 | dstPath = ""; 22 | dstSubfolderSpec = 10; 23 | files = ( 24 | 736851481CA57BD200E2FEA0 /* NSPageControl.framework in Embed Frameworks */, 25 | ); 26 | name = "Embed Frameworks"; 27 | runOnlyForDeploymentPostprocessing = 0; 28 | }; 29 | /* End PBXCopyFilesBuildPhase section */ 30 | 31 | /* Begin PBXFileReference section */ 32 | 736851131CA544A200E2FEA0 /* Example.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Example.app; sourceTree = BUILT_PRODUCTS_DIR; }; 33 | 736851161CA544A200E2FEA0 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 34 | 736851181CA544A200E2FEA0 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 35 | 7368511B1CA544A200E2FEA0 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Base.lproj/MainMenu.xib; sourceTree = ""; }; 36 | 7368511D1CA544A200E2FEA0 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 37 | 736851451CA57BCD00E2FEA0 /* NSPageControl.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = NSPageControl.framework; path = ../../Carthage/Build/Mac/NSPageControl.framework; sourceTree = ""; }; 38 | /* End PBXFileReference section */ 39 | 40 | /* Begin PBXFrameworksBuildPhase section */ 41 | 736851101CA544A200E2FEA0 /* Frameworks */ = { 42 | isa = PBXFrameworksBuildPhase; 43 | buildActionMask = 2147483647; 44 | files = ( 45 | 736851461CA57BCD00E2FEA0 /* NSPageControl.framework in Frameworks */, 46 | ); 47 | runOnlyForDeploymentPostprocessing = 0; 48 | }; 49 | /* End PBXFrameworksBuildPhase section */ 50 | 51 | /* Begin PBXGroup section */ 52 | 7368510A1CA544A200E2FEA0 = { 53 | isa = PBXGroup; 54 | children = ( 55 | 736851151CA544A200E2FEA0 /* Example */, 56 | 736851141CA544A200E2FEA0 /* Products */, 57 | ); 58 | sourceTree = ""; 59 | }; 60 | 736851141CA544A200E2FEA0 /* Products */ = { 61 | isa = PBXGroup; 62 | children = ( 63 | 736851131CA544A200E2FEA0 /* Example.app */, 64 | ); 65 | name = Products; 66 | sourceTree = ""; 67 | }; 68 | 736851151CA544A200E2FEA0 /* Example */ = { 69 | isa = PBXGroup; 70 | children = ( 71 | 736851451CA57BCD00E2FEA0 /* NSPageControl.framework */, 72 | 736851161CA544A200E2FEA0 /* AppDelegate.swift */, 73 | 736851181CA544A200E2FEA0 /* Assets.xcassets */, 74 | 7368511A1CA544A200E2FEA0 /* MainMenu.xib */, 75 | 7368511D1CA544A200E2FEA0 /* Info.plist */, 76 | ); 77 | path = Example; 78 | sourceTree = ""; 79 | }; 80 | /* End PBXGroup section */ 81 | 82 | /* Begin PBXNativeTarget section */ 83 | 736851121CA544A200E2FEA0 /* Example */ = { 84 | isa = PBXNativeTarget; 85 | buildConfigurationList = 736851201CA544A200E2FEA0 /* Build configuration list for PBXNativeTarget "Example" */; 86 | buildPhases = ( 87 | 7368510F1CA544A200E2FEA0 /* Sources */, 88 | 736851101CA544A200E2FEA0 /* Frameworks */, 89 | 736851111CA544A200E2FEA0 /* Resources */, 90 | 736851351CA5534E00E2FEA0 /* Embed Frameworks */, 91 | ); 92 | buildRules = ( 93 | ); 94 | dependencies = ( 95 | ); 96 | name = Example; 97 | productName = Example; 98 | productReference = 736851131CA544A200E2FEA0 /* Example.app */; 99 | productType = "com.apple.product-type.application"; 100 | }; 101 | /* End PBXNativeTarget section */ 102 | 103 | /* Begin PBXProject section */ 104 | 7368510B1CA544A200E2FEA0 /* Project object */ = { 105 | isa = PBXProject; 106 | attributes = { 107 | LastSwiftUpdateCheck = 0730; 108 | LastUpgradeCheck = 0800; 109 | ORGANIZATIONNAME = "Kohei Tabata"; 110 | TargetAttributes = { 111 | 736851121CA544A200E2FEA0 = { 112 | CreatedOnToolsVersion = 7.3; 113 | LastSwiftMigration = 0800; 114 | }; 115 | }; 116 | }; 117 | buildConfigurationList = 7368510E1CA544A200E2FEA0 /* Build configuration list for PBXProject "Example" */; 118 | compatibilityVersion = "Xcode 3.2"; 119 | developmentRegion = English; 120 | hasScannedForEncodings = 0; 121 | knownRegions = ( 122 | en, 123 | Base, 124 | ); 125 | mainGroup = 7368510A1CA544A200E2FEA0; 126 | productRefGroup = 736851141CA544A200E2FEA0 /* Products */; 127 | projectDirPath = ""; 128 | projectRoot = ""; 129 | targets = ( 130 | 736851121CA544A200E2FEA0 /* Example */, 131 | ); 132 | }; 133 | /* End PBXProject section */ 134 | 135 | /* Begin PBXResourcesBuildPhase section */ 136 | 736851111CA544A200E2FEA0 /* Resources */ = { 137 | isa = PBXResourcesBuildPhase; 138 | buildActionMask = 2147483647; 139 | files = ( 140 | 736851191CA544A200E2FEA0 /* Assets.xcassets in Resources */, 141 | 7368511C1CA544A200E2FEA0 /* MainMenu.xib in Resources */, 142 | ); 143 | runOnlyForDeploymentPostprocessing = 0; 144 | }; 145 | /* End PBXResourcesBuildPhase section */ 146 | 147 | /* Begin PBXSourcesBuildPhase section */ 148 | 7368510F1CA544A200E2FEA0 /* Sources */ = { 149 | isa = PBXSourcesBuildPhase; 150 | buildActionMask = 2147483647; 151 | files = ( 152 | 736851171CA544A200E2FEA0 /* AppDelegate.swift in Sources */, 153 | ); 154 | runOnlyForDeploymentPostprocessing = 0; 155 | }; 156 | /* End PBXSourcesBuildPhase section */ 157 | 158 | /* Begin PBXVariantGroup section */ 159 | 7368511A1CA544A200E2FEA0 /* MainMenu.xib */ = { 160 | isa = PBXVariantGroup; 161 | children = ( 162 | 7368511B1CA544A200E2FEA0 /* Base */, 163 | ); 164 | name = MainMenu.xib; 165 | sourceTree = ""; 166 | }; 167 | /* End PBXVariantGroup section */ 168 | 169 | /* Begin XCBuildConfiguration section */ 170 | 7368511E1CA544A200E2FEA0 /* 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 = "-"; 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 | MACOSX_DEPLOYMENT_TARGET = 10.11; 210 | MTL_ENABLE_DEBUG_INFO = YES; 211 | ONLY_ACTIVE_ARCH = YES; 212 | SDKROOT = macosx; 213 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 214 | }; 215 | name = Debug; 216 | }; 217 | 7368511F1CA544A200E2FEA0 /* 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 = "-"; 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 | MACOSX_DEPLOYMENT_TARGET = 10.11; 251 | MTL_ENABLE_DEBUG_INFO = NO; 252 | SDKROOT = macosx; 253 | SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; 254 | }; 255 | name = Release; 256 | }; 257 | 736851211CA544A200E2FEA0 /* Debug */ = { 258 | isa = XCBuildConfiguration; 259 | buildSettings = { 260 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 261 | COMBINE_HIDPI_IMAGES = YES; 262 | FRAMEWORK_SEARCH_PATHS = ../Carthage/Build/Mac; 263 | INFOPLIST_FILE = Example/Info.plist; 264 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks"; 265 | PRODUCT_BUNDLE_IDENTIFIER = com.nerd0geek1.Example; 266 | PRODUCT_NAME = "$(TARGET_NAME)"; 267 | SWIFT_VERSION = 3.0; 268 | }; 269 | name = Debug; 270 | }; 271 | 736851221CA544A200E2FEA0 /* Release */ = { 272 | isa = XCBuildConfiguration; 273 | buildSettings = { 274 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 275 | COMBINE_HIDPI_IMAGES = YES; 276 | FRAMEWORK_SEARCH_PATHS = ../Carthage/Build/Mac; 277 | INFOPLIST_FILE = Example/Info.plist; 278 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks"; 279 | PRODUCT_BUNDLE_IDENTIFIER = com.nerd0geek1.Example; 280 | PRODUCT_NAME = "$(TARGET_NAME)"; 281 | SWIFT_VERSION = 3.0; 282 | }; 283 | name = Release; 284 | }; 285 | /* End XCBuildConfiguration section */ 286 | 287 | /* Begin XCConfigurationList section */ 288 | 7368510E1CA544A200E2FEA0 /* Build configuration list for PBXProject "Example" */ = { 289 | isa = XCConfigurationList; 290 | buildConfigurations = ( 291 | 7368511E1CA544A200E2FEA0 /* Debug */, 292 | 7368511F1CA544A200E2FEA0 /* Release */, 293 | ); 294 | defaultConfigurationIsVisible = 0; 295 | defaultConfigurationName = Release; 296 | }; 297 | 736851201CA544A200E2FEA0 /* Build configuration list for PBXNativeTarget "Example" */ = { 298 | isa = XCConfigurationList; 299 | buildConfigurations = ( 300 | 736851211CA544A200E2FEA0 /* Debug */, 301 | 736851221CA544A200E2FEA0 /* Release */, 302 | ); 303 | defaultConfigurationIsVisible = 0; 304 | defaultConfigurationName = Release; 305 | }; 306 | /* End XCConfigurationList section */ 307 | }; 308 | rootObject = 7368510B1CA544A200E2FEA0 /* Project object */; 309 | } 310 | -------------------------------------------------------------------------------- /Example/Example.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Example/Example/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.swift 3 | // Example 4 | // 5 | // Created by Kohei Tabata on 2016/03/25. 6 | // Copyright © 2016年 Kohei Tabata. All rights reserved. 7 | // 8 | 9 | import Cocoa 10 | import NSPageControl 11 | 12 | @NSApplicationMain 13 | class AppDelegate: NSObject, NSApplicationDelegate { 14 | 15 | @IBOutlet weak var window: NSWindow! 16 | private var pageControl: NSPageControl! 17 | 18 | func applicationDidFinishLaunching(_ aNotification: Notification) { 19 | setupPageControl() 20 | } 21 | 22 | func applicationWillTerminate(_ aNotification: Notification) { 23 | } 24 | 25 | // MARK: - private 26 | 27 | private func setupPageControl() { 28 | pageControl = NSPageControl() 29 | pageControl.numberOfPages = 4 30 | let width: CGFloat = 200 31 | let x: CGFloat = (window.frame.width - width) / 2 32 | pageControl.frame = CGRect(x: x, y: 20, width: 200, height: 20) 33 | window.contentView?.addSubview(pageControl) 34 | } 35 | 36 | // MARK: - IBAction 37 | 38 | @IBAction func tapPreviousButton(_ sender: NSButton) { 39 | pageControl.currentPage -= 1 40 | } 41 | 42 | @IBAction func tapNextButton(_ sender: NSButton) { 43 | pageControl.currentPage += 1 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /Example/Example/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "mac", 5 | "size" : "16x16", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "mac", 10 | "size" : "16x16", 11 | "scale" : "2x" 12 | }, 13 | { 14 | "idiom" : "mac", 15 | "size" : "32x32", 16 | "scale" : "1x" 17 | }, 18 | { 19 | "idiom" : "mac", 20 | "size" : "32x32", 21 | "scale" : "2x" 22 | }, 23 | { 24 | "idiom" : "mac", 25 | "size" : "128x128", 26 | "scale" : "1x" 27 | }, 28 | { 29 | "idiom" : "mac", 30 | "size" : "128x128", 31 | "scale" : "2x" 32 | }, 33 | { 34 | "idiom" : "mac", 35 | "size" : "256x256", 36 | "scale" : "1x" 37 | }, 38 | { 39 | "idiom" : "mac", 40 | "size" : "256x256", 41 | "scale" : "2x" 42 | }, 43 | { 44 | "idiom" : "mac", 45 | "size" : "512x512", 46 | "scale" : "1x" 47 | }, 48 | { 49 | "idiom" : "mac", 50 | "size" : "512x512", 51 | "scale" : "2x" 52 | } 53 | ], 54 | "info" : { 55 | "version" : 1, 56 | "author" : "xcode" 57 | } 58 | } -------------------------------------------------------------------------------- /Example/Example/Base.lproj/MainMenu.xib: -------------------------------------------------------------------------------- 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 | 247 | 248 | 249 | 250 | 251 | 252 | 253 | 254 | 255 | 256 | 257 | 258 | 259 | 260 | 261 | 262 | 263 | 264 | 265 | 266 | 267 | 268 | 269 | 270 | 271 | 272 | 273 | 274 | 275 | 276 | 277 | 278 | 279 | 280 | 281 | 282 | 283 | 284 | 285 | 286 | 287 | 288 | 289 | 290 | 291 | 292 | 293 | 294 | 295 | 296 | 297 | 298 | 299 | 300 | 301 | 302 | 303 | 304 | 305 | 306 | 307 | 308 | 309 | 310 | 311 | 312 | 313 | 314 | 315 | 316 | 317 | 318 | 319 | 320 | 321 | 322 | 323 | 324 | 325 | 326 | 327 | 328 | 329 | 330 | 331 | 332 | 333 | 334 | 335 | 336 | 337 | 338 | 339 | 340 | 341 | 342 | 343 | 344 | 345 | 346 | 347 | 348 | 349 | 350 | 351 | 352 | 353 | 354 | 355 | 356 | 357 | 358 | 359 | 360 | 361 | 362 | 363 | 364 | 365 | 366 | 367 | 368 | 369 | 370 | 371 | 372 | 373 | 374 | 375 | 376 | 377 | 378 | 379 | 380 | 381 | 382 | 383 | 384 | 385 | 386 | 387 | 388 | 389 | 390 | 391 | 392 | 393 | 394 | 395 | 396 | 397 | 398 | 399 | 400 | 401 | 402 | 403 | 404 | 405 | 406 | 407 | 408 | 409 | 410 | 411 | 412 | 413 | 414 | 415 | 416 | 417 | 418 | 419 | 420 | 421 | 422 | 423 | 424 | 425 | 426 | 427 | 428 | 429 | 430 | 431 | 432 | 433 | 434 | 435 | 436 | 437 | 438 | 439 | 440 | 441 | 442 | 443 | 444 | 445 | 446 | 447 | 448 | 449 | 450 | 451 | 452 | 453 | 454 | 455 | 456 | 457 | 458 | 459 | 460 | 461 | 462 | 463 | 464 | 465 | 466 | 467 | 468 | 469 | 470 | 471 | 472 | 473 | 474 | 475 | 476 | 477 | 478 | 479 | 480 | 481 | 482 | 483 | 484 | 485 | 486 | 487 | 488 | 489 | 490 | 491 | 492 | 493 | 494 | 495 | 496 | 497 | 498 | 499 | 500 | 501 | 502 | 503 | 504 | 505 | 506 | 507 | 508 | 509 | 510 | 511 | 512 | 513 | 514 | 515 | 516 | 517 | 518 | 519 | 520 | 521 | 522 | 523 | 524 | 525 | 526 | 527 | 528 | 529 | 530 | 531 | 532 | 533 | 534 | 535 | 536 | 537 | 538 | 539 | Default 540 | 541 | 542 | 543 | 544 | 545 | 546 | Left to Right 547 | 548 | 549 | 550 | 551 | 552 | 553 | Right to Left 554 | 555 | 556 | 557 | 558 | 559 | 560 | 561 | 562 | 563 | 564 | Default 565 | 566 | 567 | 568 | 569 | 570 | 571 | Left to Right 572 | 573 | 574 | 575 | 576 | 577 | 578 | Right to Left 579 | 580 | 581 | 582 | 583 | 584 | 585 | 586 | 587 | 588 | 589 | 590 | 591 | 592 | 593 | 594 | 595 | 596 | 597 | 598 | 599 | 600 | 601 | 602 | 603 | 604 | 605 | 606 | 607 | 608 | 609 | 610 | 611 | 612 | 613 | 614 | 615 | 616 | 617 | 618 | 619 | 620 | 621 | 622 | 623 | 624 | 625 | 626 | 627 | 628 | 629 | 630 | 631 | 632 | 633 | 634 | 635 | 636 | 637 | 638 | 639 | 640 | 641 | 642 | 643 | 644 | 645 | 646 | 647 | 648 | 649 | 650 | 651 | 652 | 653 | 654 | 655 | 656 | 657 | 658 | 659 | 660 | 661 | 662 | 663 | 664 | 665 | 666 | 667 | 668 | 669 | 670 | 671 | 672 | 673 | 674 | 675 | 676 | 677 | 678 | 679 | 689 | 699 | 700 | 701 | 702 | 703 | 704 | 705 | 706 | 707 | 708 | 709 | 710 | -------------------------------------------------------------------------------- /Example/Example/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIconFile 10 | 11 | CFBundleIdentifier 12 | $(PRODUCT_BUNDLE_IDENTIFIER) 13 | CFBundleInfoDictionaryVersion 14 | 6.0 15 | CFBundleName 16 | $(PRODUCT_NAME) 17 | CFBundlePackageType 18 | APPL 19 | CFBundleShortVersionString 20 | 1.0 21 | CFBundleSignature 22 | ???? 23 | CFBundleVersion 24 | 1 25 | LSMinimumSystemVersion 26 | $(MACOSX_DEPLOYMENT_TARGET) 27 | NSHumanReadableCopyright 28 | Copyright © 2016年 Kohei Tabata. All rights reserved. 29 | NSMainNibFile 30 | MainMenu 31 | NSPrincipalClass 32 | NSApplication 33 | 34 | 35 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2016 Kohei Tabata 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 | -------------------------------------------------------------------------------- /NSPageControl.podspec: -------------------------------------------------------------------------------- 1 | # 2 | # Be sure to run `pod spec lint NSPageControl.podspec' to ensure this is a 3 | # valid spec and to remove all comments including this before submitting the spec. 4 | # 5 | # To learn more about Podspec attributes see http://docs.cocoapods.org/specification.html 6 | # To see working Podspecs in the CocoaPods repo see https://github.com/CocoaPods/Specs/ 7 | # 8 | 9 | Pod::Spec.new do |s| 10 | s.name = "NSPageControl" 11 | s.version = "0.0.1" 12 | s.summary = "A page control for OS X written in Swift" 13 | s.description = <<-DESC 14 | NSPageControl is simple page control for OS X. Most of the methods are derived from the UIPageControl class in iOS. 15 | DESC 16 | s.homepage = "https://github.com/nerd0geek1/NSPageControl" 17 | s.license = { :type => "MIT", :file => "LICENSE" } 18 | s.author = { "Kohei Tabata" => "nerd0geek1@gmail.com" } 19 | s.platform = :osx, "10.9" 20 | s.source = { :git => "https://github.com/nerd0geek1/NSPageControl.git", :tag => "v0.0.1" } 21 | s.source_files = "Classes", "NSPageControl/*.{swift}" 22 | end 23 | -------------------------------------------------------------------------------- /NSPageControl.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXAggregateTarget section */ 10 | 7364B65E1E4D400200E5E9E2 /* SwiftLint */ = { 11 | isa = PBXAggregateTarget; 12 | buildConfigurationList = 7364B6611E4D400200E5E9E2 /* Build configuration list for PBXAggregateTarget "SwiftLint" */; 13 | buildPhases = ( 14 | 7364B6621E4D400C00E5E9E2 /* ShellScript */, 15 | ); 16 | dependencies = ( 17 | ); 18 | name = SwiftLint; 19 | productName = SwiftLint; 20 | }; 21 | /* End PBXAggregateTarget section */ 22 | 23 | /* Begin PBXBuildFile section */ 24 | 736850BA1CA4107900E2FEA0 /* NSPageControl.swift in Sources */ = {isa = PBXBuildFile; fileRef = 736850B91CA4107900E2FEA0 /* NSPageControl.swift */; }; 25 | 7368513D1CA5582900E2FEA0 /* NSPageControlTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7368513C1CA5582900E2FEA0 /* NSPageControlTests.swift */; }; 26 | 7368513F1CA5582900E2FEA0 /* NSPageControl.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 736850AD1CA40F1C00E2FEA0 /* NSPageControl.framework */; }; 27 | /* End PBXBuildFile section */ 28 | 29 | /* Begin PBXContainerItemProxy section */ 30 | 736851401CA5582900E2FEA0 /* PBXContainerItemProxy */ = { 31 | isa = PBXContainerItemProxy; 32 | containerPortal = 736850A41CA40F1C00E2FEA0 /* Project object */; 33 | proxyType = 1; 34 | remoteGlobalIDString = 736850AC1CA40F1C00E2FEA0; 35 | remoteInfo = NSPageControl; 36 | }; 37 | /* End PBXContainerItemProxy section */ 38 | 39 | /* Begin PBXFileReference section */ 40 | 736850AD1CA40F1C00E2FEA0 /* NSPageControl.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = NSPageControl.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 41 | 736850B21CA40F1C00E2FEA0 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 42 | 736850B91CA4107900E2FEA0 /* NSPageControl.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NSPageControl.swift; sourceTree = ""; }; 43 | 7368513A1CA5582900E2FEA0 /* NSPageControlTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = NSPageControlTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 44 | 7368513C1CA5582900E2FEA0 /* NSPageControlTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NSPageControlTests.swift; sourceTree = ""; }; 45 | 7368513E1CA5582900E2FEA0 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 46 | /* End PBXFileReference section */ 47 | 48 | /* Begin PBXFrameworksBuildPhase section */ 49 | 736850A91CA40F1C00E2FEA0 /* Frameworks */ = { 50 | isa = PBXFrameworksBuildPhase; 51 | buildActionMask = 2147483647; 52 | files = ( 53 | ); 54 | runOnlyForDeploymentPostprocessing = 0; 55 | }; 56 | 736851371CA5582900E2FEA0 /* Frameworks */ = { 57 | isa = PBXFrameworksBuildPhase; 58 | buildActionMask = 2147483647; 59 | files = ( 60 | 7368513F1CA5582900E2FEA0 /* NSPageControl.framework in Frameworks */, 61 | ); 62 | runOnlyForDeploymentPostprocessing = 0; 63 | }; 64 | /* End PBXFrameworksBuildPhase section */ 65 | 66 | /* Begin PBXGroup section */ 67 | 736850A31CA40F1C00E2FEA0 = { 68 | isa = PBXGroup; 69 | children = ( 70 | 736850AF1CA40F1C00E2FEA0 /* NSPageControl */, 71 | 7368513B1CA5582900E2FEA0 /* NSPageControlTests */, 72 | 736850AE1CA40F1C00E2FEA0 /* Products */, 73 | ); 74 | sourceTree = ""; 75 | }; 76 | 736850AE1CA40F1C00E2FEA0 /* Products */ = { 77 | isa = PBXGroup; 78 | children = ( 79 | 736850AD1CA40F1C00E2FEA0 /* NSPageControl.framework */, 80 | 7368513A1CA5582900E2FEA0 /* NSPageControlTests.xctest */, 81 | ); 82 | name = Products; 83 | sourceTree = ""; 84 | }; 85 | 736850AF1CA40F1C00E2FEA0 /* NSPageControl */ = { 86 | isa = PBXGroup; 87 | children = ( 88 | 736850B21CA40F1C00E2FEA0 /* Info.plist */, 89 | 736850B91CA4107900E2FEA0 /* NSPageControl.swift */, 90 | ); 91 | path = NSPageControl; 92 | sourceTree = ""; 93 | }; 94 | 7368513B1CA5582900E2FEA0 /* NSPageControlTests */ = { 95 | isa = PBXGroup; 96 | children = ( 97 | 7368513C1CA5582900E2FEA0 /* NSPageControlTests.swift */, 98 | 7368513E1CA5582900E2FEA0 /* Info.plist */, 99 | ); 100 | path = NSPageControlTests; 101 | sourceTree = ""; 102 | }; 103 | /* End PBXGroup section */ 104 | 105 | /* Begin PBXHeadersBuildPhase section */ 106 | 736850AA1CA40F1C00E2FEA0 /* Headers */ = { 107 | isa = PBXHeadersBuildPhase; 108 | buildActionMask = 2147483647; 109 | files = ( 110 | ); 111 | runOnlyForDeploymentPostprocessing = 0; 112 | }; 113 | /* End PBXHeadersBuildPhase section */ 114 | 115 | /* Begin PBXNativeTarget section */ 116 | 736850AC1CA40F1C00E2FEA0 /* NSPageControl */ = { 117 | isa = PBXNativeTarget; 118 | buildConfigurationList = 736850B51CA40F1C00E2FEA0 /* Build configuration list for PBXNativeTarget "NSPageControl" */; 119 | buildPhases = ( 120 | 736850A81CA40F1C00E2FEA0 /* Sources */, 121 | 736850A91CA40F1C00E2FEA0 /* Frameworks */, 122 | 736850AA1CA40F1C00E2FEA0 /* Headers */, 123 | 736850AB1CA40F1C00E2FEA0 /* Resources */, 124 | ); 125 | buildRules = ( 126 | ); 127 | dependencies = ( 128 | ); 129 | name = NSPageControl; 130 | productName = NSPageControl; 131 | productReference = 736850AD1CA40F1C00E2FEA0 /* NSPageControl.framework */; 132 | productType = "com.apple.product-type.framework"; 133 | }; 134 | 736851391CA5582900E2FEA0 /* NSPageControlTests */ = { 135 | isa = PBXNativeTarget; 136 | buildConfigurationList = 736851441CA5582900E2FEA0 /* Build configuration list for PBXNativeTarget "NSPageControlTests" */; 137 | buildPhases = ( 138 | 736851361CA5582900E2FEA0 /* Sources */, 139 | 736851371CA5582900E2FEA0 /* Frameworks */, 140 | 736851381CA5582900E2FEA0 /* Resources */, 141 | ); 142 | buildRules = ( 143 | ); 144 | dependencies = ( 145 | 736851411CA5582900E2FEA0 /* PBXTargetDependency */, 146 | ); 147 | name = NSPageControlTests; 148 | productName = NSPageControlTests; 149 | productReference = 7368513A1CA5582900E2FEA0 /* NSPageControlTests.xctest */; 150 | productType = "com.apple.product-type.bundle.unit-test"; 151 | }; 152 | /* End PBXNativeTarget section */ 153 | 154 | /* Begin PBXProject section */ 155 | 736850A41CA40F1C00E2FEA0 /* Project object */ = { 156 | isa = PBXProject; 157 | attributes = { 158 | LastSwiftUpdateCheck = 0730; 159 | LastUpgradeCheck = 0800; 160 | ORGANIZATIONNAME = "Kohei Tabata"; 161 | TargetAttributes = { 162 | 7364B65E1E4D400200E5E9E2 = { 163 | CreatedOnToolsVersion = 8.2.1; 164 | ProvisioningStyle = Automatic; 165 | }; 166 | 736850AC1CA40F1C00E2FEA0 = { 167 | CreatedOnToolsVersion = 7.3; 168 | LastSwiftMigration = 0800; 169 | }; 170 | 736851391CA5582900E2FEA0 = { 171 | CreatedOnToolsVersion = 7.3; 172 | LastSwiftMigration = 0800; 173 | }; 174 | }; 175 | }; 176 | buildConfigurationList = 736850A71CA40F1C00E2FEA0 /* Build configuration list for PBXProject "NSPageControl" */; 177 | compatibilityVersion = "Xcode 3.2"; 178 | developmentRegion = English; 179 | hasScannedForEncodings = 0; 180 | knownRegions = ( 181 | en, 182 | ); 183 | mainGroup = 736850A31CA40F1C00E2FEA0; 184 | productRefGroup = 736850AE1CA40F1C00E2FEA0 /* Products */; 185 | projectDirPath = ""; 186 | projectRoot = ""; 187 | targets = ( 188 | 736850AC1CA40F1C00E2FEA0 /* NSPageControl */, 189 | 736851391CA5582900E2FEA0 /* NSPageControlTests */, 190 | 7364B65E1E4D400200E5E9E2 /* SwiftLint */, 191 | ); 192 | }; 193 | /* End PBXProject section */ 194 | 195 | /* Begin PBXResourcesBuildPhase section */ 196 | 736850AB1CA40F1C00E2FEA0 /* Resources */ = { 197 | isa = PBXResourcesBuildPhase; 198 | buildActionMask = 2147483647; 199 | files = ( 200 | ); 201 | runOnlyForDeploymentPostprocessing = 0; 202 | }; 203 | 736851381CA5582900E2FEA0 /* Resources */ = { 204 | isa = PBXResourcesBuildPhase; 205 | buildActionMask = 2147483647; 206 | files = ( 207 | ); 208 | runOnlyForDeploymentPostprocessing = 0; 209 | }; 210 | /* End PBXResourcesBuildPhase section */ 211 | 212 | /* Begin PBXShellScriptBuildPhase section */ 213 | 7364B6621E4D400C00E5E9E2 /* ShellScript */ = { 214 | isa = PBXShellScriptBuildPhase; 215 | buildActionMask = 2147483647; 216 | files = ( 217 | ); 218 | inputPaths = ( 219 | ); 220 | outputPaths = ( 221 | ); 222 | runOnlyForDeploymentPostprocessing = 0; 223 | shellPath = /bin/sh; 224 | shellScript = "if which swiftlint >/dev/null; then\n swiftlint\nelse\n echo \"warning: SwiftLint not installed, download from https://github.com/realm/SwiftLint\"\nfi"; 225 | }; 226 | /* End PBXShellScriptBuildPhase section */ 227 | 228 | /* Begin PBXSourcesBuildPhase section */ 229 | 736850A81CA40F1C00E2FEA0 /* Sources */ = { 230 | isa = PBXSourcesBuildPhase; 231 | buildActionMask = 2147483647; 232 | files = ( 233 | 736850BA1CA4107900E2FEA0 /* NSPageControl.swift in Sources */, 234 | ); 235 | runOnlyForDeploymentPostprocessing = 0; 236 | }; 237 | 736851361CA5582900E2FEA0 /* Sources */ = { 238 | isa = PBXSourcesBuildPhase; 239 | buildActionMask = 2147483647; 240 | files = ( 241 | 7368513D1CA5582900E2FEA0 /* NSPageControlTests.swift in Sources */, 242 | ); 243 | runOnlyForDeploymentPostprocessing = 0; 244 | }; 245 | /* End PBXSourcesBuildPhase section */ 246 | 247 | /* Begin PBXTargetDependency section */ 248 | 736851411CA5582900E2FEA0 /* PBXTargetDependency */ = { 249 | isa = PBXTargetDependency; 250 | target = 736850AC1CA40F1C00E2FEA0 /* NSPageControl */; 251 | targetProxy = 736851401CA5582900E2FEA0 /* PBXContainerItemProxy */; 252 | }; 253 | /* End PBXTargetDependency section */ 254 | 255 | /* Begin XCBuildConfiguration section */ 256 | 7364B65F1E4D400200E5E9E2 /* Debug */ = { 257 | isa = XCBuildConfiguration; 258 | buildSettings = { 259 | PRODUCT_NAME = "$(TARGET_NAME)"; 260 | }; 261 | name = Debug; 262 | }; 263 | 7364B6601E4D400200E5E9E2 /* Release */ = { 264 | isa = XCBuildConfiguration; 265 | buildSettings = { 266 | PRODUCT_NAME = "$(TARGET_NAME)"; 267 | }; 268 | name = Release; 269 | }; 270 | 736850B31CA40F1C00E2FEA0 /* Debug */ = { 271 | isa = XCBuildConfiguration; 272 | buildSettings = { 273 | ALWAYS_SEARCH_USER_PATHS = NO; 274 | CLANG_ANALYZER_NONNULL = YES; 275 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 276 | CLANG_CXX_LIBRARY = "libc++"; 277 | CLANG_ENABLE_MODULES = YES; 278 | CLANG_ENABLE_OBJC_ARC = YES; 279 | CLANG_WARN_BOOL_CONVERSION = YES; 280 | CLANG_WARN_CONSTANT_CONVERSION = YES; 281 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 282 | CLANG_WARN_EMPTY_BODY = YES; 283 | CLANG_WARN_ENUM_CONVERSION = YES; 284 | CLANG_WARN_INFINITE_RECURSION = YES; 285 | CLANG_WARN_INT_CONVERSION = YES; 286 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 287 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 288 | CLANG_WARN_UNREACHABLE_CODE = YES; 289 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 290 | CODE_SIGN_IDENTITY = "-"; 291 | COPY_PHASE_STRIP = NO; 292 | CURRENT_PROJECT_VERSION = 1; 293 | DEBUG_INFORMATION_FORMAT = dwarf; 294 | ENABLE_STRICT_OBJC_MSGSEND = YES; 295 | ENABLE_TESTABILITY = YES; 296 | GCC_C_LANGUAGE_STANDARD = gnu99; 297 | GCC_DYNAMIC_NO_PIC = NO; 298 | GCC_NO_COMMON_BLOCKS = YES; 299 | GCC_OPTIMIZATION_LEVEL = 0; 300 | GCC_PREPROCESSOR_DEFINITIONS = ( 301 | "DEBUG=1", 302 | "$(inherited)", 303 | ); 304 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 305 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 306 | GCC_WARN_UNDECLARED_SELECTOR = YES; 307 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 308 | GCC_WARN_UNUSED_FUNCTION = YES; 309 | GCC_WARN_UNUSED_VARIABLE = YES; 310 | MACOSX_DEPLOYMENT_TARGET = 10.9; 311 | MTL_ENABLE_DEBUG_INFO = YES; 312 | ONLY_ACTIVE_ARCH = YES; 313 | SDKROOT = macosx; 314 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 315 | VERSIONING_SYSTEM = "apple-generic"; 316 | VERSION_INFO_PREFIX = ""; 317 | }; 318 | name = Debug; 319 | }; 320 | 736850B41CA40F1C00E2FEA0 /* Release */ = { 321 | isa = XCBuildConfiguration; 322 | buildSettings = { 323 | ALWAYS_SEARCH_USER_PATHS = NO; 324 | CLANG_ANALYZER_NONNULL = YES; 325 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 326 | CLANG_CXX_LIBRARY = "libc++"; 327 | CLANG_ENABLE_MODULES = YES; 328 | CLANG_ENABLE_OBJC_ARC = YES; 329 | CLANG_WARN_BOOL_CONVERSION = YES; 330 | CLANG_WARN_CONSTANT_CONVERSION = YES; 331 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 332 | CLANG_WARN_EMPTY_BODY = YES; 333 | CLANG_WARN_ENUM_CONVERSION = YES; 334 | CLANG_WARN_INFINITE_RECURSION = YES; 335 | CLANG_WARN_INT_CONVERSION = YES; 336 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 337 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 338 | CLANG_WARN_UNREACHABLE_CODE = YES; 339 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 340 | CODE_SIGN_IDENTITY = "-"; 341 | COPY_PHASE_STRIP = NO; 342 | CURRENT_PROJECT_VERSION = 1; 343 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 344 | ENABLE_NS_ASSERTIONS = NO; 345 | ENABLE_STRICT_OBJC_MSGSEND = YES; 346 | GCC_C_LANGUAGE_STANDARD = gnu99; 347 | GCC_NO_COMMON_BLOCKS = YES; 348 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 349 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 350 | GCC_WARN_UNDECLARED_SELECTOR = YES; 351 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 352 | GCC_WARN_UNUSED_FUNCTION = YES; 353 | GCC_WARN_UNUSED_VARIABLE = YES; 354 | MACOSX_DEPLOYMENT_TARGET = 10.9; 355 | MTL_ENABLE_DEBUG_INFO = NO; 356 | SDKROOT = macosx; 357 | SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; 358 | VERSIONING_SYSTEM = "apple-generic"; 359 | VERSION_INFO_PREFIX = ""; 360 | }; 361 | name = Release; 362 | }; 363 | 736850B61CA40F1C00E2FEA0 /* Debug */ = { 364 | isa = XCBuildConfiguration; 365 | buildSettings = { 366 | CLANG_ENABLE_MODULES = YES; 367 | CODE_SIGN_IDENTITY = ""; 368 | COMBINE_HIDPI_IMAGES = YES; 369 | DEFINES_MODULE = YES; 370 | DYLIB_COMPATIBILITY_VERSION = 1; 371 | DYLIB_CURRENT_VERSION = 1; 372 | DYLIB_INSTALL_NAME_BASE = "@rpath"; 373 | FRAMEWORK_VERSION = A; 374 | INFOPLIST_FILE = NSPageControl/Info.plist; 375 | INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; 376 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/Frameworks"; 377 | PRODUCT_BUNDLE_IDENTIFIER = com.nerd0geek1.NSPageControl; 378 | PRODUCT_NAME = "$(TARGET_NAME)"; 379 | SKIP_INSTALL = YES; 380 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 381 | SWIFT_VERSION = 3.0; 382 | }; 383 | name = Debug; 384 | }; 385 | 736850B71CA40F1C00E2FEA0 /* Release */ = { 386 | isa = XCBuildConfiguration; 387 | buildSettings = { 388 | CLANG_ENABLE_MODULES = YES; 389 | CODE_SIGN_IDENTITY = ""; 390 | COMBINE_HIDPI_IMAGES = YES; 391 | DEFINES_MODULE = YES; 392 | DYLIB_COMPATIBILITY_VERSION = 1; 393 | DYLIB_CURRENT_VERSION = 1; 394 | DYLIB_INSTALL_NAME_BASE = "@rpath"; 395 | FRAMEWORK_VERSION = A; 396 | INFOPLIST_FILE = NSPageControl/Info.plist; 397 | INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; 398 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/Frameworks"; 399 | PRODUCT_BUNDLE_IDENTIFIER = com.nerd0geek1.NSPageControl; 400 | PRODUCT_NAME = "$(TARGET_NAME)"; 401 | SKIP_INSTALL = YES; 402 | SWIFT_VERSION = 3.0; 403 | }; 404 | name = Release; 405 | }; 406 | 736851421CA5582900E2FEA0 /* Debug */ = { 407 | isa = XCBuildConfiguration; 408 | buildSettings = { 409 | COMBINE_HIDPI_IMAGES = YES; 410 | INFOPLIST_FILE = NSPageControlTests/Info.plist; 411 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks"; 412 | MACOSX_DEPLOYMENT_TARGET = 10.11; 413 | PRODUCT_BUNDLE_IDENTIFIER = com.nerd0geek1.NSPageControlTests; 414 | PRODUCT_NAME = "$(TARGET_NAME)"; 415 | SWIFT_VERSION = 3.0; 416 | }; 417 | name = Debug; 418 | }; 419 | 736851431CA5582900E2FEA0 /* Release */ = { 420 | isa = XCBuildConfiguration; 421 | buildSettings = { 422 | COMBINE_HIDPI_IMAGES = YES; 423 | INFOPLIST_FILE = NSPageControlTests/Info.plist; 424 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks"; 425 | MACOSX_DEPLOYMENT_TARGET = 10.11; 426 | PRODUCT_BUNDLE_IDENTIFIER = com.nerd0geek1.NSPageControlTests; 427 | PRODUCT_NAME = "$(TARGET_NAME)"; 428 | SWIFT_VERSION = 3.0; 429 | }; 430 | name = Release; 431 | }; 432 | /* End XCBuildConfiguration section */ 433 | 434 | /* Begin XCConfigurationList section */ 435 | 7364B6611E4D400200E5E9E2 /* Build configuration list for PBXAggregateTarget "SwiftLint" */ = { 436 | isa = XCConfigurationList; 437 | buildConfigurations = ( 438 | 7364B65F1E4D400200E5E9E2 /* Debug */, 439 | 7364B6601E4D400200E5E9E2 /* Release */, 440 | ); 441 | defaultConfigurationIsVisible = 0; 442 | }; 443 | 736850A71CA40F1C00E2FEA0 /* Build configuration list for PBXProject "NSPageControl" */ = { 444 | isa = XCConfigurationList; 445 | buildConfigurations = ( 446 | 736850B31CA40F1C00E2FEA0 /* Debug */, 447 | 736850B41CA40F1C00E2FEA0 /* Release */, 448 | ); 449 | defaultConfigurationIsVisible = 0; 450 | defaultConfigurationName = Release; 451 | }; 452 | 736850B51CA40F1C00E2FEA0 /* Build configuration list for PBXNativeTarget "NSPageControl" */ = { 453 | isa = XCConfigurationList; 454 | buildConfigurations = ( 455 | 736850B61CA40F1C00E2FEA0 /* Debug */, 456 | 736850B71CA40F1C00E2FEA0 /* Release */, 457 | ); 458 | defaultConfigurationIsVisible = 0; 459 | defaultConfigurationName = Release; 460 | }; 461 | 736851441CA5582900E2FEA0 /* Build configuration list for PBXNativeTarget "NSPageControlTests" */ = { 462 | isa = XCConfigurationList; 463 | buildConfigurations = ( 464 | 736851421CA5582900E2FEA0 /* Debug */, 465 | 736851431CA5582900E2FEA0 /* Release */, 466 | ); 467 | defaultConfigurationIsVisible = 0; 468 | defaultConfigurationName = Release; 469 | }; 470 | /* End XCConfigurationList section */ 471 | }; 472 | rootObject = 736850A41CA40F1C00E2FEA0 /* Project object */; 473 | } 474 | -------------------------------------------------------------------------------- /NSPageControl.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /NSPageControl.xcodeproj/xcshareddata/xcschemes/NSPageControl.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 29 | 35 | 36 | 37 | 38 | 39 | 44 | 45 | 47 | 53 | 54 | 55 | 56 | 57 | 63 | 64 | 65 | 66 | 67 | 68 | 78 | 79 | 85 | 86 | 87 | 88 | 89 | 90 | 96 | 97 | 103 | 104 | 105 | 106 | 108 | 109 | 112 | 113 | 114 | -------------------------------------------------------------------------------- /NSPageControl/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 | FMWK 17 | CFBundleShortVersionString 18 | 0.0.1 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | $(CURRENT_PROJECT_VERSION) 23 | NSHumanReadableCopyright 24 | Copyright © 2016年 Kohei Tabata. All rights reserved. 25 | NSPrincipalClass 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /NSPageControl/NSPageControl.swift: -------------------------------------------------------------------------------- 1 | // 2 | // NSPageControl.swift 3 | // NSPageControl 4 | // 5 | // Created by Kohei Tabata on 2016/03/24. 6 | // Copyright © 2016年 Kohei Tabata. All rights reserved. 7 | // 8 | 9 | import Cocoa 10 | 11 | public class NSPageControl: NSView { 12 | 13 | public var numberOfPages: Int = 0 14 | public var currentPage: Int = 0 { 15 | didSet(oldValue) { 16 | if currentPage < 0 { 17 | currentPage = 0 18 | } 19 | if currentPage > numberOfPages - 1 { 20 | currentPage = numberOfPages - 1 21 | } 22 | didSetCurrentPage(oldValue, newlySelectedPage: currentPage) 23 | } 24 | } 25 | public var hidesForSinglePage: Bool = true 26 | public var pageIndicatorTintColor: NSColor = NSColor.darkGray 27 | public var currentPageIndicatorTintColor: NSColor = NSColor.white 28 | public var animationDuration: CFTimeInterval = 0.04 29 | public var dotLength: CGFloat = 8.0 30 | public var dotMargin: CGFloat = 12.0 31 | 32 | private var dotLayers: [CAShapeLayer] = [] 33 | 34 | // MARK: - lifecycle 35 | 36 | public override func draw(_ dirtyRect: NSRect) { 37 | super.draw(dirtyRect) 38 | 39 | let dotWidthSum: CGFloat = dotLength * CGFloat(numberOfPages) 40 | let marginWidthSum: CGFloat = dotMargin * CGFloat((numberOfPages - 1)) 41 | let minimumRequiredWidth: CGFloat = dotWidthSum + marginWidthSum 42 | 43 | let hasEnoughHeight: Bool = dirtyRect.height >= dotLength 44 | let hasEnoughWidth: Bool = dirtyRect.width >= minimumRequiredWidth 45 | if !hasEnoughWidth || !hasEnoughHeight { 46 | Swift.print("dirtyRect doesn't have enough space to draw all dots") 47 | Swift.print("current Rect :\(dirtyRect)") 48 | Swift.print("required Size:\(CGSize(width: minimumRequiredWidth, height: dotLength))") 49 | } 50 | 51 | for layer in dotLayers { 52 | layer.removeFromSuperlayer() 53 | } 54 | dotLayers = [] 55 | self.layer = CALayer() 56 | self.wantsLayer = true 57 | 58 | for i: Int in 0.. CABasicAnimation { 92 | let fillColorAnimation: CABasicAnimation = CABasicAnimation(keyPath: "fillColor") 93 | fillColorAnimation.toValue = color.cgColor 94 | fillColorAnimation.duration = animationDuration 95 | fillColorAnimation.fillMode = kCAFillModeForwards 96 | fillColorAnimation.isRemovedOnCompletion = false 97 | return fillColorAnimation 98 | } 99 | } 100 | -------------------------------------------------------------------------------- /NSPageControlTests/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 | -------------------------------------------------------------------------------- /NSPageControlTests/NSPageControlTests.swift: -------------------------------------------------------------------------------- 1 | // 2 | // NSPageControlTests.swift 3 | // NSPageControlTests 4 | // 5 | // Created by Kohei Tabata on 2016/03/25. 6 | // Copyright © 2016年 Kohei Tabata. All rights reserved. 7 | // 8 | 9 | import NSPageControl 10 | import XCTest 11 | 12 | class NSPageControlTests: XCTestCase { 13 | override func setUp() { 14 | super.setUp() 15 | } 16 | 17 | override func tearDown() { 18 | super.tearDown() 19 | } 20 | 21 | func testToSetValidCurrentPage() { 22 | let pageControl: NSPageControl = NSPageControl(frame: NSRect.init(x: 0, y: 0, width: 100, height: 10)) 23 | pageControl.numberOfPages = 3 24 | pageControl.draw(pageControl.frame) 25 | XCTAssertTrue(pageControl.currentPage == 0) 26 | pageControl.currentPage = 1 27 | XCTAssertTrue(pageControl.currentPage == 1) 28 | pageControl.currentPage = 2 29 | XCTAssertTrue(pageControl.currentPage == 2) 30 | } 31 | 32 | func testToSetInvalidCurrentPage() { 33 | let pageControl: NSPageControl = NSPageControl(frame: NSRect.init(x: 0, y: 0, width: 100, height: 10)) 34 | pageControl.numberOfPages = 3 35 | pageControl.draw(pageControl.frame) 36 | XCTAssertTrue(pageControl.currentPage == 0) 37 | pageControl.currentPage = 3 38 | XCTAssertTrue(pageControl.currentPage == 2) 39 | pageControl.currentPage = -1 40 | XCTAssertTrue(pageControl.currentPage == 0) 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # NSPageControl 2 | [![Build Status](https://travis-ci.org/nerd0geek1/NSPageControl.svg?branch=master)](https://travis-ci.org/nerd0geek1/NSPageControl) 3 | [![Carthage Compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat)](https://github.com/Carthage/Carthage) 4 | 5 | This is PageControl Component for OS X. Inspired by UIPageControl and [BFPageControl](https://github.com/bfolder/BFPageControl). 6 | 7 | ## Demo 8 | ![Demo.gif](https://github.com/nerd0geek1/NSPageControl/raw/master/Demo.gif) 9 | 10 | ##Installation 11 | NSPageControl supports multiple methods for installing the library in a project. 12 | 13 | ##Installation with CocoaPods 14 | To integrate NSPageControl into your Xcode project using CocoaPods, specify it in your Podfile: 15 | ``` 16 | platform :osx, '10.9' 17 | use_frameworks! 18 | pod 'NSPageControl' 19 | ``` 20 | 21 | Then, run the following command: 22 | ``` 23 | $ pod install 24 | ``` 25 | 26 | ## Requirements 27 | - iOS 9.0+, OS X 10.10+ 28 | - Xcode 8.0 or above 29 | 30 | Logger is now supporting Swift3.0. 31 | If you want to use with Swift2.2, please use Swift2.2 branch. 32 | 33 | ##Installation with Carthage 34 | To integrate NSPageControl into your Xcode project using Carthage, specify it in your Cartfile: 35 | ``` 36 | github "nerd0geek1/NSPageControl" 37 | ``` 38 | 39 | Then, run the following command: 40 | ``` 41 | $ carthage update 42 | ``` 43 | 44 | ##Example 45 | See Example for a working example. 46 | Before running Example project, please execute below commands. 47 | ``` 48 | $ carthage build --no-skip-current 49 | ``` 50 | 51 | ##License 52 | This software is Open Source under the MIT license, see LICENSE for details. 53 | --------------------------------------------------------------------------------