├── README.md ├── screenshot.png ├── swift-piechart.xcodeproj ├── project.pbxproj ├── project.xcworkspace │ ├── contents.xcworkspacedata │ ├── xcshareddata │ │ └── swift-piechart.xccheckout │ └── xcuserdata │ │ └── zemirco.xcuserdatad │ │ └── UserInterfaceState.xcuserstate └── xcuserdata │ └── zemirco.xcuserdatad │ ├── xcdebugger │ └── Breakpoints_v2.xcbkptlist │ └── xcschemes │ ├── swift-piechart.xcscheme │ └── xcschememanagement.plist ├── swift-piechart ├── AppDelegate.swift ├── Base.lproj │ ├── LaunchScreen.xib │ └── Main.storyboard ├── Images.xcassets │ └── AppIcon.appiconset │ │ └── Contents.json ├── Info.plist ├── Piechart.swift └── ViewController.swift └── swift-piechartTests ├── Info.plist └── swift_piechartTests.swift /README.md: -------------------------------------------------------------------------------- 1 | 2 | # Swift Piechart 3 | 4 | Piechart library for iOS written in Swift. 5 | 6 | ## Usage 7 | 8 | ```swift 9 | var total: CGFloat = 20 10 | 11 | var error = Piechart.Slice() 12 | error.value = 4 / total 13 | error.color = UIColor.magentaColor() 14 | error.text = "Error" 15 | 16 | var zero = Piechart.Slice() 17 | zero.value = 6 / total 18 | zero.color = UIColor.blueColor() 19 | zero.text = "Zero" 20 | 21 | var win = Piechart.Slice() 22 | win.value = 10 / total 23 | win.color = UIColor.orangeColor() 24 | win.text = "Winner" 25 | 26 | var piechart = Piechart() 27 | piechart.title = "Service" 28 | piechart.activeSlice = 0 29 | piechart.slices = [error, zero, win] 30 | ``` 31 | 32 | ![piechart demo](https://raw.githubusercontent.com/zemirco/swift-piechart/master/screenshot.png) 33 | 34 | ## Properties 35 | 36 | - `title`: String - Piechart title for center top position. 37 | - `subtitle`: String - Piechart subtitle below title. 38 | - `info`: String - Some additional information below subtitle. 39 | - `slices`: [Slice] - Data for Piechart. Each `slice` has properties: 40 | - `color`: UIColor - Slice color 41 | - `value`: CGFloat - Slice percentage value from 0 to 1. 42 | - `text`: String - Slice text / description 43 | - `radius`: Radius 44 | - `inner`: CGFloat = `40` - Radius for inner circle. 45 | - `outer`: CGFLoat = `60` - Radius for outer circle. 46 | - `activeSlice`: Int = `0` - Index for highlighted slice. 47 | 48 | ## Delegates 49 | 50 | ```swift 51 | func setSubtitle(slice: Piechart.Slice) -> String 52 | ``` 53 | 54 | Set subtitle label text for given `slice`. 55 | 56 | ```swift 57 | func setInfo(slice: Piechart.Slice) -> String 58 | ``` 59 | 60 | Set info label text for given `slice`. 61 | 62 | ## License 63 | 64 | MIT 65 | -------------------------------------------------------------------------------- /screenshot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zemirco/swift-piechart/af1975e58ef096d2c382da69adc1cb754972ac65/screenshot.png -------------------------------------------------------------------------------- /swift-piechart.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 3BAFC8AE1ABB405E00DAB397 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3BAFC8AD1ABB405E00DAB397 /* AppDelegate.swift */; }; 11 | 3BAFC8B01ABB405E00DAB397 /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3BAFC8AF1ABB405E00DAB397 /* ViewController.swift */; }; 12 | 3BAFC8B31ABB405E00DAB397 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 3BAFC8B11ABB405E00DAB397 /* Main.storyboard */; }; 13 | 3BAFC8B51ABB405E00DAB397 /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 3BAFC8B41ABB405E00DAB397 /* Images.xcassets */; }; 14 | 3BAFC8B81ABB405E00DAB397 /* LaunchScreen.xib in Resources */ = {isa = PBXBuildFile; fileRef = 3BAFC8B61ABB405E00DAB397 /* LaunchScreen.xib */; }; 15 | 3BAFC8C41ABB405E00DAB397 /* swift_piechartTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3BAFC8C31ABB405E00DAB397 /* swift_piechartTests.swift */; }; 16 | 3BAFC8CE1ABB409700DAB397 /* Piechart.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3BAFC8CD1ABB409700DAB397 /* Piechart.swift */; }; 17 | /* End PBXBuildFile section */ 18 | 19 | /* Begin PBXContainerItemProxy section */ 20 | 3BAFC8BE1ABB405E00DAB397 /* PBXContainerItemProxy */ = { 21 | isa = PBXContainerItemProxy; 22 | containerPortal = 3BAFC8A01ABB405E00DAB397 /* Project object */; 23 | proxyType = 1; 24 | remoteGlobalIDString = 3BAFC8A71ABB405E00DAB397; 25 | remoteInfo = "swift-piechart"; 26 | }; 27 | /* End PBXContainerItemProxy section */ 28 | 29 | /* Begin PBXFileReference section */ 30 | 3BAFC8A81ABB405E00DAB397 /* swift-piechart.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "swift-piechart.app"; sourceTree = BUILT_PRODUCTS_DIR; }; 31 | 3BAFC8AC1ABB405E00DAB397 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 32 | 3BAFC8AD1ABB405E00DAB397 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 33 | 3BAFC8AF1ABB405E00DAB397 /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = ""; }; 34 | 3BAFC8B21ABB405E00DAB397 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 35 | 3BAFC8B41ABB405E00DAB397 /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Images.xcassets; sourceTree = ""; }; 36 | 3BAFC8B71ABB405E00DAB397 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Base.lproj/LaunchScreen.xib; sourceTree = ""; }; 37 | 3BAFC8BD1ABB405E00DAB397 /* swift-piechartTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = "swift-piechartTests.xctest"; sourceTree = BUILT_PRODUCTS_DIR; }; 38 | 3BAFC8C21ABB405E00DAB397 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 39 | 3BAFC8C31ABB405E00DAB397 /* swift_piechartTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = swift_piechartTests.swift; sourceTree = ""; }; 40 | 3BAFC8CD1ABB409700DAB397 /* Piechart.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Piechart.swift; sourceTree = ""; }; 41 | /* End PBXFileReference section */ 42 | 43 | /* Begin PBXFrameworksBuildPhase section */ 44 | 3BAFC8A51ABB405E00DAB397 /* Frameworks */ = { 45 | isa = PBXFrameworksBuildPhase; 46 | buildActionMask = 2147483647; 47 | files = ( 48 | ); 49 | runOnlyForDeploymentPostprocessing = 0; 50 | }; 51 | 3BAFC8BA1ABB405E00DAB397 /* Frameworks */ = { 52 | isa = PBXFrameworksBuildPhase; 53 | buildActionMask = 2147483647; 54 | files = ( 55 | ); 56 | runOnlyForDeploymentPostprocessing = 0; 57 | }; 58 | /* End PBXFrameworksBuildPhase section */ 59 | 60 | /* Begin PBXGroup section */ 61 | 3BAFC89F1ABB405E00DAB397 = { 62 | isa = PBXGroup; 63 | children = ( 64 | 3BAFC8AA1ABB405E00DAB397 /* swift-piechart */, 65 | 3BAFC8C01ABB405E00DAB397 /* swift-piechartTests */, 66 | 3BAFC8A91ABB405E00DAB397 /* Products */, 67 | ); 68 | sourceTree = ""; 69 | }; 70 | 3BAFC8A91ABB405E00DAB397 /* Products */ = { 71 | isa = PBXGroup; 72 | children = ( 73 | 3BAFC8A81ABB405E00DAB397 /* swift-piechart.app */, 74 | 3BAFC8BD1ABB405E00DAB397 /* swift-piechartTests.xctest */, 75 | ); 76 | name = Products; 77 | sourceTree = ""; 78 | }; 79 | 3BAFC8AA1ABB405E00DAB397 /* swift-piechart */ = { 80 | isa = PBXGroup; 81 | children = ( 82 | 3BAFC8AD1ABB405E00DAB397 /* AppDelegate.swift */, 83 | 3BAFC8CD1ABB409700DAB397 /* Piechart.swift */, 84 | 3BAFC8AF1ABB405E00DAB397 /* ViewController.swift */, 85 | 3BAFC8B11ABB405E00DAB397 /* Main.storyboard */, 86 | 3BAFC8AB1ABB405E00DAB397 /* Supporting Files */, 87 | ); 88 | path = "swift-piechart"; 89 | sourceTree = ""; 90 | }; 91 | 3BAFC8AB1ABB405E00DAB397 /* Supporting Files */ = { 92 | isa = PBXGroup; 93 | children = ( 94 | 3BAFC8B41ABB405E00DAB397 /* Images.xcassets */, 95 | 3BAFC8B61ABB405E00DAB397 /* LaunchScreen.xib */, 96 | 3BAFC8AC1ABB405E00DAB397 /* Info.plist */, 97 | ); 98 | name = "Supporting Files"; 99 | sourceTree = ""; 100 | }; 101 | 3BAFC8C01ABB405E00DAB397 /* swift-piechartTests */ = { 102 | isa = PBXGroup; 103 | children = ( 104 | 3BAFC8C31ABB405E00DAB397 /* swift_piechartTests.swift */, 105 | 3BAFC8C11ABB405E00DAB397 /* Supporting Files */, 106 | ); 107 | path = "swift-piechartTests"; 108 | sourceTree = ""; 109 | }; 110 | 3BAFC8C11ABB405E00DAB397 /* Supporting Files */ = { 111 | isa = PBXGroup; 112 | children = ( 113 | 3BAFC8C21ABB405E00DAB397 /* Info.plist */, 114 | ); 115 | name = "Supporting Files"; 116 | sourceTree = ""; 117 | }; 118 | /* End PBXGroup section */ 119 | 120 | /* Begin PBXNativeTarget section */ 121 | 3BAFC8A71ABB405E00DAB397 /* swift-piechart */ = { 122 | isa = PBXNativeTarget; 123 | buildConfigurationList = 3BAFC8C71ABB405E00DAB397 /* Build configuration list for PBXNativeTarget "swift-piechart" */; 124 | buildPhases = ( 125 | 3BAFC8A41ABB405E00DAB397 /* Sources */, 126 | 3BAFC8A51ABB405E00DAB397 /* Frameworks */, 127 | 3BAFC8A61ABB405E00DAB397 /* Resources */, 128 | ); 129 | buildRules = ( 130 | ); 131 | dependencies = ( 132 | ); 133 | name = "swift-piechart"; 134 | productName = "swift-piechart"; 135 | productReference = 3BAFC8A81ABB405E00DAB397 /* swift-piechart.app */; 136 | productType = "com.apple.product-type.application"; 137 | }; 138 | 3BAFC8BC1ABB405E00DAB397 /* swift-piechartTests */ = { 139 | isa = PBXNativeTarget; 140 | buildConfigurationList = 3BAFC8CA1ABB405E00DAB397 /* Build configuration list for PBXNativeTarget "swift-piechartTests" */; 141 | buildPhases = ( 142 | 3BAFC8B91ABB405E00DAB397 /* Sources */, 143 | 3BAFC8BA1ABB405E00DAB397 /* Frameworks */, 144 | 3BAFC8BB1ABB405E00DAB397 /* Resources */, 145 | ); 146 | buildRules = ( 147 | ); 148 | dependencies = ( 149 | 3BAFC8BF1ABB405E00DAB397 /* PBXTargetDependency */, 150 | ); 151 | name = "swift-piechartTests"; 152 | productName = "swift-piechartTests"; 153 | productReference = 3BAFC8BD1ABB405E00DAB397 /* swift-piechartTests.xctest */; 154 | productType = "com.apple.product-type.bundle.unit-test"; 155 | }; 156 | /* End PBXNativeTarget section */ 157 | 158 | /* Begin PBXProject section */ 159 | 3BAFC8A01ABB405E00DAB397 /* Project object */ = { 160 | isa = PBXProject; 161 | attributes = { 162 | LastSwiftMigration = 0700; 163 | LastSwiftUpdateCheck = 0700; 164 | LastUpgradeCheck = 0800; 165 | ORGANIZATIONNAME = name; 166 | TargetAttributes = { 167 | 3BAFC8A71ABB405E00DAB397 = { 168 | CreatedOnToolsVersion = 6.3; 169 | LastSwiftMigration = 0800; 170 | }; 171 | 3BAFC8BC1ABB405E00DAB397 = { 172 | CreatedOnToolsVersion = 6.3; 173 | LastSwiftMigration = 0800; 174 | TestTargetID = 3BAFC8A71ABB405E00DAB397; 175 | }; 176 | }; 177 | }; 178 | buildConfigurationList = 3BAFC8A31ABB405E00DAB397 /* Build configuration list for PBXProject "swift-piechart" */; 179 | compatibilityVersion = "Xcode 3.2"; 180 | developmentRegion = English; 181 | hasScannedForEncodings = 0; 182 | knownRegions = ( 183 | en, 184 | Base, 185 | ); 186 | mainGroup = 3BAFC89F1ABB405E00DAB397; 187 | productRefGroup = 3BAFC8A91ABB405E00DAB397 /* Products */; 188 | projectDirPath = ""; 189 | projectRoot = ""; 190 | targets = ( 191 | 3BAFC8A71ABB405E00DAB397 /* swift-piechart */, 192 | 3BAFC8BC1ABB405E00DAB397 /* swift-piechartTests */, 193 | ); 194 | }; 195 | /* End PBXProject section */ 196 | 197 | /* Begin PBXResourcesBuildPhase section */ 198 | 3BAFC8A61ABB405E00DAB397 /* Resources */ = { 199 | isa = PBXResourcesBuildPhase; 200 | buildActionMask = 2147483647; 201 | files = ( 202 | 3BAFC8B31ABB405E00DAB397 /* Main.storyboard in Resources */, 203 | 3BAFC8B81ABB405E00DAB397 /* LaunchScreen.xib in Resources */, 204 | 3BAFC8B51ABB405E00DAB397 /* Images.xcassets in Resources */, 205 | ); 206 | runOnlyForDeploymentPostprocessing = 0; 207 | }; 208 | 3BAFC8BB1ABB405E00DAB397 /* Resources */ = { 209 | isa = PBXResourcesBuildPhase; 210 | buildActionMask = 2147483647; 211 | files = ( 212 | ); 213 | runOnlyForDeploymentPostprocessing = 0; 214 | }; 215 | /* End PBXResourcesBuildPhase section */ 216 | 217 | /* Begin PBXSourcesBuildPhase section */ 218 | 3BAFC8A41ABB405E00DAB397 /* Sources */ = { 219 | isa = PBXSourcesBuildPhase; 220 | buildActionMask = 2147483647; 221 | files = ( 222 | 3BAFC8B01ABB405E00DAB397 /* ViewController.swift in Sources */, 223 | 3BAFC8CE1ABB409700DAB397 /* Piechart.swift in Sources */, 224 | 3BAFC8AE1ABB405E00DAB397 /* AppDelegate.swift in Sources */, 225 | ); 226 | runOnlyForDeploymentPostprocessing = 0; 227 | }; 228 | 3BAFC8B91ABB405E00DAB397 /* Sources */ = { 229 | isa = PBXSourcesBuildPhase; 230 | buildActionMask = 2147483647; 231 | files = ( 232 | 3BAFC8C41ABB405E00DAB397 /* swift_piechartTests.swift in Sources */, 233 | ); 234 | runOnlyForDeploymentPostprocessing = 0; 235 | }; 236 | /* End PBXSourcesBuildPhase section */ 237 | 238 | /* Begin PBXTargetDependency section */ 239 | 3BAFC8BF1ABB405E00DAB397 /* PBXTargetDependency */ = { 240 | isa = PBXTargetDependency; 241 | target = 3BAFC8A71ABB405E00DAB397 /* swift-piechart */; 242 | targetProxy = 3BAFC8BE1ABB405E00DAB397 /* PBXContainerItemProxy */; 243 | }; 244 | /* End PBXTargetDependency section */ 245 | 246 | /* Begin PBXVariantGroup section */ 247 | 3BAFC8B11ABB405E00DAB397 /* Main.storyboard */ = { 248 | isa = PBXVariantGroup; 249 | children = ( 250 | 3BAFC8B21ABB405E00DAB397 /* Base */, 251 | ); 252 | name = Main.storyboard; 253 | sourceTree = ""; 254 | }; 255 | 3BAFC8B61ABB405E00DAB397 /* LaunchScreen.xib */ = { 256 | isa = PBXVariantGroup; 257 | children = ( 258 | 3BAFC8B71ABB405E00DAB397 /* Base */, 259 | ); 260 | name = LaunchScreen.xib; 261 | sourceTree = ""; 262 | }; 263 | /* End PBXVariantGroup section */ 264 | 265 | /* Begin XCBuildConfiguration section */ 266 | 3BAFC8C51ABB405E00DAB397 /* Debug */ = { 267 | isa = XCBuildConfiguration; 268 | buildSettings = { 269 | ALWAYS_SEARCH_USER_PATHS = NO; 270 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 271 | CLANG_CXX_LIBRARY = "libc++"; 272 | CLANG_ENABLE_MODULES = YES; 273 | CLANG_ENABLE_OBJC_ARC = YES; 274 | CLANG_WARN_BOOL_CONVERSION = YES; 275 | CLANG_WARN_CONSTANT_CONVERSION = YES; 276 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 277 | CLANG_WARN_EMPTY_BODY = YES; 278 | CLANG_WARN_ENUM_CONVERSION = YES; 279 | CLANG_WARN_INFINITE_RECURSION = YES; 280 | CLANG_WARN_INT_CONVERSION = YES; 281 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 282 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 283 | CLANG_WARN_UNREACHABLE_CODE = YES; 284 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 285 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 286 | COPY_PHASE_STRIP = NO; 287 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 288 | ENABLE_STRICT_OBJC_MSGSEND = YES; 289 | ENABLE_TESTABILITY = YES; 290 | GCC_C_LANGUAGE_STANDARD = gnu99; 291 | GCC_DYNAMIC_NO_PIC = NO; 292 | GCC_NO_COMMON_BLOCKS = YES; 293 | GCC_OPTIMIZATION_LEVEL = 0; 294 | GCC_PREPROCESSOR_DEFINITIONS = ( 295 | "DEBUG=1", 296 | "$(inherited)", 297 | ); 298 | GCC_SYMBOLS_PRIVATE_EXTERN = NO; 299 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 300 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 301 | GCC_WARN_UNDECLARED_SELECTOR = YES; 302 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 303 | GCC_WARN_UNUSED_FUNCTION = YES; 304 | GCC_WARN_UNUSED_VARIABLE = YES; 305 | IPHONEOS_DEPLOYMENT_TARGET = 8.3; 306 | MTL_ENABLE_DEBUG_INFO = YES; 307 | ONLY_ACTIVE_ARCH = YES; 308 | SDKROOT = iphoneos; 309 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 310 | }; 311 | name = Debug; 312 | }; 313 | 3BAFC8C61ABB405E00DAB397 /* Release */ = { 314 | isa = XCBuildConfiguration; 315 | buildSettings = { 316 | ALWAYS_SEARCH_USER_PATHS = NO; 317 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 318 | CLANG_CXX_LIBRARY = "libc++"; 319 | CLANG_ENABLE_MODULES = YES; 320 | CLANG_ENABLE_OBJC_ARC = YES; 321 | CLANG_WARN_BOOL_CONVERSION = YES; 322 | CLANG_WARN_CONSTANT_CONVERSION = YES; 323 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 324 | CLANG_WARN_EMPTY_BODY = YES; 325 | CLANG_WARN_ENUM_CONVERSION = YES; 326 | CLANG_WARN_INFINITE_RECURSION = YES; 327 | CLANG_WARN_INT_CONVERSION = YES; 328 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 329 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 330 | CLANG_WARN_UNREACHABLE_CODE = YES; 331 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 332 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 333 | COPY_PHASE_STRIP = NO; 334 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 335 | ENABLE_NS_ASSERTIONS = NO; 336 | ENABLE_STRICT_OBJC_MSGSEND = YES; 337 | GCC_C_LANGUAGE_STANDARD = gnu99; 338 | GCC_NO_COMMON_BLOCKS = YES; 339 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 340 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 341 | GCC_WARN_UNDECLARED_SELECTOR = YES; 342 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 343 | GCC_WARN_UNUSED_FUNCTION = YES; 344 | GCC_WARN_UNUSED_VARIABLE = YES; 345 | IPHONEOS_DEPLOYMENT_TARGET = 8.3; 346 | MTL_ENABLE_DEBUG_INFO = NO; 347 | SDKROOT = iphoneos; 348 | SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; 349 | VALIDATE_PRODUCT = YES; 350 | }; 351 | name = Release; 352 | }; 353 | 3BAFC8C81ABB405E00DAB397 /* Debug */ = { 354 | isa = XCBuildConfiguration; 355 | buildSettings = { 356 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 357 | INFOPLIST_FILE = "swift-piechart/Info.plist"; 358 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 359 | PRODUCT_BUNDLE_IDENTIFIER = "identifier.$(PRODUCT_NAME:rfc1034identifier)"; 360 | PRODUCT_NAME = "$(TARGET_NAME)"; 361 | SWIFT_VERSION = 3.0; 362 | }; 363 | name = Debug; 364 | }; 365 | 3BAFC8C91ABB405E00DAB397 /* Release */ = { 366 | isa = XCBuildConfiguration; 367 | buildSettings = { 368 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 369 | INFOPLIST_FILE = "swift-piechart/Info.plist"; 370 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 371 | PRODUCT_BUNDLE_IDENTIFIER = "identifier.$(PRODUCT_NAME:rfc1034identifier)"; 372 | PRODUCT_NAME = "$(TARGET_NAME)"; 373 | SWIFT_VERSION = 3.0; 374 | }; 375 | name = Release; 376 | }; 377 | 3BAFC8CB1ABB405E00DAB397 /* Debug */ = { 378 | isa = XCBuildConfiguration; 379 | buildSettings = { 380 | BUNDLE_LOADER = "$(TEST_HOST)"; 381 | FRAMEWORK_SEARCH_PATHS = ( 382 | "$(SDKROOT)/Developer/Library/Frameworks", 383 | "$(inherited)", 384 | ); 385 | GCC_PREPROCESSOR_DEFINITIONS = ( 386 | "DEBUG=1", 387 | "$(inherited)", 388 | ); 389 | INFOPLIST_FILE = "swift-piechartTests/Info.plist"; 390 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 391 | PRODUCT_BUNDLE_IDENTIFIER = "identifier.$(PRODUCT_NAME:rfc1034identifier)"; 392 | PRODUCT_NAME = "$(TARGET_NAME)"; 393 | SWIFT_VERSION = 3.0; 394 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/swift-piechart.app/swift-piechart"; 395 | }; 396 | name = Debug; 397 | }; 398 | 3BAFC8CC1ABB405E00DAB397 /* Release */ = { 399 | isa = XCBuildConfiguration; 400 | buildSettings = { 401 | BUNDLE_LOADER = "$(TEST_HOST)"; 402 | FRAMEWORK_SEARCH_PATHS = ( 403 | "$(SDKROOT)/Developer/Library/Frameworks", 404 | "$(inherited)", 405 | ); 406 | INFOPLIST_FILE = "swift-piechartTests/Info.plist"; 407 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 408 | PRODUCT_BUNDLE_IDENTIFIER = "identifier.$(PRODUCT_NAME:rfc1034identifier)"; 409 | PRODUCT_NAME = "$(TARGET_NAME)"; 410 | SWIFT_VERSION = 3.0; 411 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/swift-piechart.app/swift-piechart"; 412 | }; 413 | name = Release; 414 | }; 415 | /* End XCBuildConfiguration section */ 416 | 417 | /* Begin XCConfigurationList section */ 418 | 3BAFC8A31ABB405E00DAB397 /* Build configuration list for PBXProject "swift-piechart" */ = { 419 | isa = XCConfigurationList; 420 | buildConfigurations = ( 421 | 3BAFC8C51ABB405E00DAB397 /* Debug */, 422 | 3BAFC8C61ABB405E00DAB397 /* Release */, 423 | ); 424 | defaultConfigurationIsVisible = 0; 425 | defaultConfigurationName = Release; 426 | }; 427 | 3BAFC8C71ABB405E00DAB397 /* Build configuration list for PBXNativeTarget "swift-piechart" */ = { 428 | isa = XCConfigurationList; 429 | buildConfigurations = ( 430 | 3BAFC8C81ABB405E00DAB397 /* Debug */, 431 | 3BAFC8C91ABB405E00DAB397 /* Release */, 432 | ); 433 | defaultConfigurationIsVisible = 0; 434 | defaultConfigurationName = Release; 435 | }; 436 | 3BAFC8CA1ABB405E00DAB397 /* Build configuration list for PBXNativeTarget "swift-piechartTests" */ = { 437 | isa = XCConfigurationList; 438 | buildConfigurations = ( 439 | 3BAFC8CB1ABB405E00DAB397 /* Debug */, 440 | 3BAFC8CC1ABB405E00DAB397 /* Release */, 441 | ); 442 | defaultConfigurationIsVisible = 0; 443 | defaultConfigurationName = Release; 444 | }; 445 | /* End XCConfigurationList section */ 446 | }; 447 | rootObject = 3BAFC8A01ABB405E00DAB397 /* Project object */; 448 | } 449 | -------------------------------------------------------------------------------- /swift-piechart.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /swift-piechart.xcodeproj/project.xcworkspace/xcshareddata/swift-piechart.xccheckout: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDESourceControlProjectFavoriteDictionaryKey 6 | 7 | IDESourceControlProjectIdentifier 8 | D671EE2B-1FCD-4738-A783-FAF8604401F9 9 | IDESourceControlProjectName 10 | swift-piechart 11 | IDESourceControlProjectOriginsDictionary 12 | 13 | 4BA289C6DBD5FB4E5D80DE50A9B16A870F05EC60 14 | github.com:zemirco/swift-piechart.git 15 | 16 | IDESourceControlProjectPath 17 | swift-piechart.xcodeproj 18 | IDESourceControlProjectRelativeInstallPathDictionary 19 | 20 | 4BA289C6DBD5FB4E5D80DE50A9B16A870F05EC60 21 | ../.. 22 | 23 | IDESourceControlProjectURL 24 | github.com:zemirco/swift-piechart.git 25 | IDESourceControlProjectVersion 26 | 111 27 | IDESourceControlProjectWCCIdentifier 28 | 4BA289C6DBD5FB4E5D80DE50A9B16A870F05EC60 29 | IDESourceControlProjectWCConfigurations 30 | 31 | 32 | IDESourceControlRepositoryExtensionIdentifierKey 33 | public.vcs.git 34 | IDESourceControlWCCIdentifierKey 35 | 4BA289C6DBD5FB4E5D80DE50A9B16A870F05EC60 36 | IDESourceControlWCCName 37 | swift-piechart 38 | 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /swift-piechart.xcodeproj/project.xcworkspace/xcuserdata/zemirco.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zemirco/swift-piechart/af1975e58ef096d2c382da69adc1cb754972ac65/swift-piechart.xcodeproj/project.xcworkspace/xcuserdata/zemirco.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /swift-piechart.xcodeproj/xcuserdata/zemirco.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | -------------------------------------------------------------------------------- /swift-piechart.xcodeproj/xcuserdata/zemirco.xcuserdatad/xcschemes/swift-piechart.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 | 80 | 86 | 87 | 88 | 89 | 90 | 91 | 97 | 99 | 105 | 106 | 107 | 108 | 110 | 111 | 114 | 115 | 116 | -------------------------------------------------------------------------------- /swift-piechart.xcodeproj/xcuserdata/zemirco.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | swift-piechart.xcscheme 8 | 9 | orderHint 10 | 0 11 | 12 | 13 | SuppressBuildableAutocreation 14 | 15 | 3BAFC8A71ABB405E00DAB397 16 | 17 | primary 18 | 19 | 20 | 3BAFC8BC1ABB405E00DAB397 21 | 22 | primary 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /swift-piechart/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.swift 3 | // swift-piechart 4 | // 5 | // Created by Mirco Zeiss on 3/19/15. 6 | // Copyright (c) 2015 name. 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 | -------------------------------------------------------------------------------- /swift-piechart/Base.lproj/LaunchScreen.xib: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 20 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /swift-piechart/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 | -------------------------------------------------------------------------------- /swift-piechart/Images.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 | } -------------------------------------------------------------------------------- /swift-piechart/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 | -------------------------------------------------------------------------------- /swift-piechart/Piechart.swift: -------------------------------------------------------------------------------- 1 | 2 | import UIKit 3 | 4 | 5 | public protocol PiechartDelegate { 6 | func setSubtitle(_ total: CGFloat, slice: Piechart.Slice) -> String 7 | func setInfo(_ total: CGFloat, slice: Piechart.Slice) -> String 8 | } 9 | 10 | 11 | 12 | /** 13 | * Piechart 14 | */ 15 | open class Piechart: UIControl { 16 | 17 | /** 18 | * Slice 19 | */ 20 | public struct Slice { 21 | public var color: UIColor! 22 | public var value: CGFloat! 23 | public var text: String! 24 | } 25 | 26 | /** 27 | * Radius 28 | */ 29 | public struct Radius { 30 | public var inner: CGFloat = 40 31 | public var outer: CGFloat = 60 32 | } 33 | 34 | /** 35 | * private 36 | */ 37 | fileprivate var titleLabel: UILabel! 38 | fileprivate var subtitleLabel: UILabel! 39 | fileprivate var infoLabel: UILabel! 40 | fileprivate var total: CGFloat! 41 | 42 | 43 | /** 44 | * public 45 | */ 46 | open var radius: Radius = Radius() 47 | open var activeSlice: Int = 0 48 | open var delegate: PiechartDelegate? 49 | 50 | open var title: String = "title" { 51 | didSet { 52 | titleLabel.text = title 53 | } 54 | } 55 | 56 | open var subtitle: String = "subtitle" { 57 | didSet { 58 | subtitleLabel.text = subtitle 59 | } 60 | } 61 | 62 | open var info: String = "info" { 63 | didSet { 64 | infoLabel.text = info 65 | } 66 | } 67 | 68 | open var slices: [Slice] = [] { 69 | didSet { 70 | total = 0 71 | for slice in slices { 72 | total = slice.value + total 73 | } 74 | } 75 | } 76 | 77 | 78 | 79 | /** 80 | * methods 81 | */ 82 | required public init?(coder aDecoder: NSCoder) { 83 | super.init(coder: aDecoder) 84 | } 85 | 86 | override public init(frame: CGRect) { 87 | super.init(frame: frame) 88 | self.backgroundColor = UIColor.clear 89 | 90 | self.addTarget(self, action: #selector(Piechart.click), for: .touchUpInside) 91 | 92 | titleLabel = UILabel() 93 | titleLabel.text = title 94 | titleLabel.font = UIFont.preferredFont(forTextStyle: UIFontTextStyle.headline) 95 | titleLabel.textAlignment = .center 96 | titleLabel.translatesAutoresizingMaskIntoConstraints = false 97 | self.addSubview(titleLabel) 98 | 99 | subtitleLabel = UILabel() 100 | subtitleLabel.text = subtitle 101 | subtitleLabel.font = UIFont.preferredFont(forTextStyle: UIFontTextStyle.caption1) 102 | subtitleLabel.textColor = UIColor.gray 103 | subtitleLabel.textAlignment = .center 104 | subtitleLabel.translatesAutoresizingMaskIntoConstraints = false 105 | self.addSubview(subtitleLabel) 106 | 107 | infoLabel = UILabel() 108 | infoLabel.text = subtitle 109 | infoLabel.font = UIFont.preferredFont(forTextStyle: UIFontTextStyle.caption1) 110 | infoLabel.textColor = UIColor.gray 111 | infoLabel.textAlignment = .center 112 | infoLabel.translatesAutoresizingMaskIntoConstraints = false 113 | self.addSubview(infoLabel) 114 | 115 | self.addConstraint(NSLayoutConstraint(item: titleLabel, attribute: .centerX, relatedBy: .equal, toItem: self, attribute: .centerX, multiplier: 1, constant: 0)) 116 | self.addConstraint(NSLayoutConstraint(item: titleLabel, attribute: .bottom, relatedBy: .equal, toItem: self, attribute: .centerY, multiplier: 1, constant: 0)) 117 | 118 | self.addConstraint(NSLayoutConstraint(item: subtitleLabel, attribute: .centerX, relatedBy: .equal, toItem: self, attribute: .centerX, multiplier: 1, constant: 0)) 119 | self.addConstraint(NSLayoutConstraint(item: subtitleLabel, attribute: .top, relatedBy: .equal, toItem: self, attribute: .centerY, multiplier: 1, constant: 0)) 120 | 121 | self.addConstraint(NSLayoutConstraint(item: infoLabel, attribute: .centerX, relatedBy: .equal, toItem: self, attribute: .centerX, multiplier: 1, constant: 0)) 122 | self.addConstraint(NSLayoutConstraint(item: infoLabel, attribute: .top, relatedBy: .equal, toItem: subtitleLabel, attribute: .bottom, multiplier: 1, constant: 0)) 123 | } 124 | 125 | convenience init() { 126 | self.init(frame: CGRect.zero) 127 | } 128 | 129 | open override func draw(_ rect: CGRect) { 130 | super.draw(rect) 131 | 132 | let center = CGPoint(x: bounds.width / 2, y: bounds.height / 2) 133 | var startValue: CGFloat = 0 134 | var startAngle: CGFloat = 0 135 | var endValue: CGFloat = 0 136 | var endAngle: CGFloat = 0 137 | 138 | for (index, slice) in slices.enumerated() { 139 | 140 | startAngle = (startValue * 2 * CGFloat(Double.pi)) - CGFloat(Double.pi / 2) 141 | endValue = startValue + (slice.value / self.total) 142 | endAngle = (endValue * 2 * CGFloat(Double.pi)) - CGFloat(Double.pi / 2) 143 | 144 | let path = UIBezierPath() 145 | path.move(to: center) 146 | path.addArc(withCenter: center, radius: radius.outer, startAngle: startAngle, endAngle: endAngle, clockwise: true) 147 | 148 | var color = UIColor(red: 230/255.0, green: 230/255.0, blue: 230/255.0, alpha: 1) 149 | if (index == activeSlice) { 150 | color = slice.color 151 | subtitle = delegate?.setSubtitle(self.total, slice: slice) ?? "subtitle" 152 | info = delegate?.setInfo(self.total, slice: slice) ?? "info" 153 | } 154 | color.setFill() 155 | path.fill() 156 | 157 | // add white border to slice 158 | UIColor.white.setStroke() 159 | path.stroke() 160 | 161 | // increase start value for next slice 162 | startValue += slice.value / self.total 163 | } 164 | 165 | // create center donut hole 166 | let innerPath = UIBezierPath() 167 | innerPath.move(to: center) 168 | innerPath.addArc(withCenter: center, radius: radius.inner, startAngle: 0, endAngle: CGFloat(Double.pi) * 2, clockwise: true) 169 | UIColor.white.setFill() 170 | innerPath.fill() 171 | } 172 | 173 | func click() { 174 | activeSlice += 1 175 | if activeSlice >= slices.count { 176 | activeSlice = 0 177 | } 178 | setNeedsDisplay() 179 | } 180 | 181 | 182 | } 183 | -------------------------------------------------------------------------------- /swift-piechart/ViewController.swift: -------------------------------------------------------------------------------- 1 | 2 | import UIKit 3 | 4 | class ViewController: UIViewController, PiechartDelegate { 5 | 6 | override func viewDidLoad() { 7 | super.viewDidLoad() 8 | 9 | var views: [String: UIView] = [:] 10 | 11 | var error = Piechart.Slice() 12 | error.value = 4 13 | error.color = UIColor.magenta 14 | error.text = "Error" 15 | 16 | var zero = Piechart.Slice() 17 | zero.value = 6 18 | zero.color = UIColor.blue 19 | zero.text = "Zero" 20 | 21 | var win = Piechart.Slice() 22 | win.value = 10 23 | win.color = UIColor.orange 24 | win.text = "Winner" 25 | 26 | let piechart = Piechart() 27 | piechart.delegate = self 28 | piechart.title = "Service" 29 | piechart.activeSlice = 2 30 | piechart.layer.borderWidth = 1 31 | piechart.slices = [error, zero, win] 32 | 33 | piechart.translatesAutoresizingMaskIntoConstraints = false 34 | view.addSubview(piechart) 35 | views["piechart"] = piechart 36 | view.addConstraints(NSLayoutConstraint.constraints(withVisualFormat: "H:|-[piechart]-|", options: [], metrics: nil, views: views)) 37 | view.addConstraints(NSLayoutConstraint.constraints(withVisualFormat: "V:|-200-[piechart(==200)]", options: [], metrics: nil, views: views)) 38 | 39 | } 40 | 41 | override func didReceiveMemoryWarning() { 42 | super.didReceiveMemoryWarning() 43 | } 44 | 45 | func setSubtitle(_ total: CGFloat, slice: Piechart.Slice) -> String { 46 | return "\(Int(slice.value / total * 100))% \(slice.text!)" 47 | } 48 | 49 | func setInfo(_ total: CGFloat, slice: Piechart.Slice) -> String { 50 | return "\(Int(slice.value))/\(Int(total))" 51 | } 52 | 53 | 54 | } 55 | 56 | -------------------------------------------------------------------------------- /swift-piechartTests/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 | -------------------------------------------------------------------------------- /swift-piechartTests/swift_piechartTests.swift: -------------------------------------------------------------------------------- 1 | // 2 | // swift_piechartTests.swift 3 | // swift-piechartTests 4 | // 5 | // Created by Mirco Zeiss on 3/19/15. 6 | // Copyright (c) 2015 name. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | import XCTest 11 | 12 | class swift_piechartTests: XCTestCase { 13 | 14 | override func setUp() { 15 | super.setUp() 16 | // Put setup code here. This method is called before the invocation of each test method in the class. 17 | } 18 | 19 | override func tearDown() { 20 | // Put teardown code here. This method is called after the invocation of each test method in the class. 21 | super.tearDown() 22 | } 23 | 24 | func testExample() { 25 | // This is an example of a functional test case. 26 | XCTAssert(true, "Pass") 27 | } 28 | 29 | func testPerformanceExample() { 30 | // This is an example of a performance test case. 31 | self.measure() { 32 | // Put the code you want to measure the time of here. 33 | } 34 | } 35 | 36 | } 37 | --------------------------------------------------------------------------------