├── .gitignore ├── Demo └── JZAvatarImageViewDemo │ ├── JZAvatarImageViewDemo.xcodeproj │ ├── project.pbxproj │ └── project.xcworkspace │ │ └── contents.xcworkspacedata │ ├── JZAvatarImageViewDemo │ ├── AppDelegate.swift │ ├── Base.lproj │ │ └── Main.storyboard │ ├── Images.xcassets │ │ ├── AppIcon.appiconset │ │ │ └── Contents.json │ │ └── waz.imageset │ │ │ ├── Contents.json │ │ │ └── waz.jpg │ ├── Info.plist │ └── ViewController.swift │ └── JZAvatarImageViewDemoTests │ ├── Info.plist │ └── JZAvatarImageViewDemoTests.swift ├── JZAvatarNSImageView.swift ├── LICENSE ├── README.md └── screenshot └── screenshot.png /.gitignore: -------------------------------------------------------------------------------- 1 | # Xcode 2 | # 3 | build/ 4 | *.pbxuser 5 | !default.pbxuser 6 | *.mode1v3 7 | !default.mode1v3 8 | *.mode2v3 9 | !default.mode2v3 10 | *.perspectivev3 11 | !default.perspectivev3 12 | xcuserdata 13 | *.xccheckout 14 | *.moved-aside 15 | DerivedData 16 | *.hmap 17 | *.ipa 18 | *.xcuserstate 19 | 20 | # CocoaPods 21 | # 22 | # We recommend against adding the Pods directory to your .gitignore. However 23 | # you should judge for yourself, the pros and cons are mentioned at: 24 | # http://guides.cocoapods.org/using/using-cocoapods.html#should-i-ignore-the-pods-directory-in-source-control 25 | # 26 | # Pods/ 27 | 28 | # Carthage 29 | # 30 | # Add this line if you want to avoid checking in source code from Carthage dependencies. 31 | # Carthage/Checkouts 32 | 33 | Carthage/Build 34 | -------------------------------------------------------------------------------- /Demo/JZAvatarImageViewDemo/JZAvatarImageViewDemo.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | D4EF3F481B91399200A887B6 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = D4EF3F471B91399200A887B6 /* AppDelegate.swift */; }; 11 | D4EF3F4A1B91399200A887B6 /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = D4EF3F491B91399200A887B6 /* ViewController.swift */; }; 12 | D4EF3F4C1B91399200A887B6 /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = D4EF3F4B1B91399200A887B6 /* Images.xcassets */; }; 13 | D4EF3F4F1B91399200A887B6 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = D4EF3F4D1B91399200A887B6 /* Main.storyboard */; }; 14 | D4EF3F5B1B91399200A887B6 /* JZAvatarImageViewDemoTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = D4EF3F5A1B91399200A887B6 /* JZAvatarImageViewDemoTests.swift */; }; 15 | D4EF3F651B913A1700A887B6 /* JZAvatarNSImageView.swift in Sources */ = {isa = PBXBuildFile; fileRef = D4EF3F641B913A1700A887B6 /* JZAvatarNSImageView.swift */; }; 16 | /* End PBXBuildFile section */ 17 | 18 | /* Begin PBXContainerItemProxy section */ 19 | D4EF3F551B91399200A887B6 /* PBXContainerItemProxy */ = { 20 | isa = PBXContainerItemProxy; 21 | containerPortal = D4EF3F3A1B91399200A887B6 /* Project object */; 22 | proxyType = 1; 23 | remoteGlobalIDString = D4EF3F411B91399200A887B6; 24 | remoteInfo = JZAvatarImageViewDemo; 25 | }; 26 | /* End PBXContainerItemProxy section */ 27 | 28 | /* Begin PBXFileReference section */ 29 | D4EF3F421B91399200A887B6 /* JZAvatarImageViewDemo.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = JZAvatarImageViewDemo.app; sourceTree = BUILT_PRODUCTS_DIR; }; 30 | D4EF3F461B91399200A887B6 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 31 | D4EF3F471B91399200A887B6 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 32 | D4EF3F491B91399200A887B6 /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = ""; }; 33 | D4EF3F4B1B91399200A887B6 /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Images.xcassets; sourceTree = ""; }; 34 | D4EF3F4E1B91399200A887B6 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 35 | D4EF3F541B91399200A887B6 /* JZAvatarImageViewDemoTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = JZAvatarImageViewDemoTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 36 | D4EF3F591B91399200A887B6 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 37 | D4EF3F5A1B91399200A887B6 /* JZAvatarImageViewDemoTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = JZAvatarImageViewDemoTests.swift; sourceTree = ""; }; 38 | D4EF3F641B913A1700A887B6 /* JZAvatarNSImageView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = JZAvatarNSImageView.swift; path = ../../../JZAvatarNSImageView.swift; sourceTree = ""; }; 39 | /* End PBXFileReference section */ 40 | 41 | /* Begin PBXFrameworksBuildPhase section */ 42 | D4EF3F3F1B91399200A887B6 /* Frameworks */ = { 43 | isa = PBXFrameworksBuildPhase; 44 | buildActionMask = 2147483647; 45 | files = ( 46 | ); 47 | runOnlyForDeploymentPostprocessing = 0; 48 | }; 49 | D4EF3F511B91399200A887B6 /* Frameworks */ = { 50 | isa = PBXFrameworksBuildPhase; 51 | buildActionMask = 2147483647; 52 | files = ( 53 | ); 54 | runOnlyForDeploymentPostprocessing = 0; 55 | }; 56 | /* End PBXFrameworksBuildPhase section */ 57 | 58 | /* Begin PBXGroup section */ 59 | D4EF3F391B91399200A887B6 = { 60 | isa = PBXGroup; 61 | children = ( 62 | D4EF3F441B91399200A887B6 /* JZAvatarImageViewDemo */, 63 | D4EF3F571B91399200A887B6 /* JZAvatarImageViewDemoTests */, 64 | D4EF3F431B91399200A887B6 /* Products */, 65 | ); 66 | sourceTree = ""; 67 | }; 68 | D4EF3F431B91399200A887B6 /* Products */ = { 69 | isa = PBXGroup; 70 | children = ( 71 | D4EF3F421B91399200A887B6 /* JZAvatarImageViewDemo.app */, 72 | D4EF3F541B91399200A887B6 /* JZAvatarImageViewDemoTests.xctest */, 73 | ); 74 | name = Products; 75 | sourceTree = ""; 76 | }; 77 | D4EF3F441B91399200A887B6 /* JZAvatarImageViewDemo */ = { 78 | isa = PBXGroup; 79 | children = ( 80 | D4EF3F641B913A1700A887B6 /* JZAvatarNSImageView.swift */, 81 | D4EF3F471B91399200A887B6 /* AppDelegate.swift */, 82 | D4EF3F491B91399200A887B6 /* ViewController.swift */, 83 | D4EF3F4B1B91399200A887B6 /* Images.xcassets */, 84 | D4EF3F4D1B91399200A887B6 /* Main.storyboard */, 85 | D4EF3F451B91399200A887B6 /* Supporting Files */, 86 | ); 87 | path = JZAvatarImageViewDemo; 88 | sourceTree = ""; 89 | }; 90 | D4EF3F451B91399200A887B6 /* Supporting Files */ = { 91 | isa = PBXGroup; 92 | children = ( 93 | D4EF3F461B91399200A887B6 /* Info.plist */, 94 | ); 95 | name = "Supporting Files"; 96 | sourceTree = ""; 97 | }; 98 | D4EF3F571B91399200A887B6 /* JZAvatarImageViewDemoTests */ = { 99 | isa = PBXGroup; 100 | children = ( 101 | D4EF3F5A1B91399200A887B6 /* JZAvatarImageViewDemoTests.swift */, 102 | D4EF3F581B91399200A887B6 /* Supporting Files */, 103 | ); 104 | path = JZAvatarImageViewDemoTests; 105 | sourceTree = ""; 106 | }; 107 | D4EF3F581B91399200A887B6 /* Supporting Files */ = { 108 | isa = PBXGroup; 109 | children = ( 110 | D4EF3F591B91399200A887B6 /* Info.plist */, 111 | ); 112 | name = "Supporting Files"; 113 | sourceTree = ""; 114 | }; 115 | /* End PBXGroup section */ 116 | 117 | /* Begin PBXNativeTarget section */ 118 | D4EF3F411B91399200A887B6 /* JZAvatarImageViewDemo */ = { 119 | isa = PBXNativeTarget; 120 | buildConfigurationList = D4EF3F5E1B91399200A887B6 /* Build configuration list for PBXNativeTarget "JZAvatarImageViewDemo" */; 121 | buildPhases = ( 122 | D4EF3F3E1B91399200A887B6 /* Sources */, 123 | D4EF3F3F1B91399200A887B6 /* Frameworks */, 124 | D4EF3F401B91399200A887B6 /* Resources */, 125 | ); 126 | buildRules = ( 127 | ); 128 | dependencies = ( 129 | ); 130 | name = JZAvatarImageViewDemo; 131 | productName = JZAvatarImageViewDemo; 132 | productReference = D4EF3F421B91399200A887B6 /* JZAvatarImageViewDemo.app */; 133 | productType = "com.apple.product-type.application"; 134 | }; 135 | D4EF3F531B91399200A887B6 /* JZAvatarImageViewDemoTests */ = { 136 | isa = PBXNativeTarget; 137 | buildConfigurationList = D4EF3F611B91399200A887B6 /* Build configuration list for PBXNativeTarget "JZAvatarImageViewDemoTests" */; 138 | buildPhases = ( 139 | D4EF3F501B91399200A887B6 /* Sources */, 140 | D4EF3F511B91399200A887B6 /* Frameworks */, 141 | D4EF3F521B91399200A887B6 /* Resources */, 142 | ); 143 | buildRules = ( 144 | ); 145 | dependencies = ( 146 | D4EF3F561B91399200A887B6 /* PBXTargetDependency */, 147 | ); 148 | name = JZAvatarImageViewDemoTests; 149 | productName = JZAvatarImageViewDemoTests; 150 | productReference = D4EF3F541B91399200A887B6 /* JZAvatarImageViewDemoTests.xctest */; 151 | productType = "com.apple.product-type.bundle.unit-test"; 152 | }; 153 | /* End PBXNativeTarget section */ 154 | 155 | /* Begin PBXProject section */ 156 | D4EF3F3A1B91399200A887B6 /* Project object */ = { 157 | isa = PBXProject; 158 | attributes = { 159 | LastSwiftUpdateCheck = 0700; 160 | LastUpgradeCheck = 0640; 161 | ORGANIZATIONNAME = Joey; 162 | TargetAttributes = { 163 | D4EF3F411B91399200A887B6 = { 164 | CreatedOnToolsVersion = 6.4; 165 | }; 166 | D4EF3F531B91399200A887B6 = { 167 | CreatedOnToolsVersion = 6.4; 168 | TestTargetID = D4EF3F411B91399200A887B6; 169 | }; 170 | }; 171 | }; 172 | buildConfigurationList = D4EF3F3D1B91399200A887B6 /* Build configuration list for PBXProject "JZAvatarImageViewDemo" */; 173 | compatibilityVersion = "Xcode 3.2"; 174 | developmentRegion = English; 175 | hasScannedForEncodings = 0; 176 | knownRegions = ( 177 | en, 178 | Base, 179 | ); 180 | mainGroup = D4EF3F391B91399200A887B6; 181 | productRefGroup = D4EF3F431B91399200A887B6 /* Products */; 182 | projectDirPath = ""; 183 | projectRoot = ""; 184 | targets = ( 185 | D4EF3F411B91399200A887B6 /* JZAvatarImageViewDemo */, 186 | D4EF3F531B91399200A887B6 /* JZAvatarImageViewDemoTests */, 187 | ); 188 | }; 189 | /* End PBXProject section */ 190 | 191 | /* Begin PBXResourcesBuildPhase section */ 192 | D4EF3F401B91399200A887B6 /* Resources */ = { 193 | isa = PBXResourcesBuildPhase; 194 | buildActionMask = 2147483647; 195 | files = ( 196 | D4EF3F4C1B91399200A887B6 /* Images.xcassets in Resources */, 197 | D4EF3F4F1B91399200A887B6 /* Main.storyboard in Resources */, 198 | ); 199 | runOnlyForDeploymentPostprocessing = 0; 200 | }; 201 | D4EF3F521B91399200A887B6 /* Resources */ = { 202 | isa = PBXResourcesBuildPhase; 203 | buildActionMask = 2147483647; 204 | files = ( 205 | ); 206 | runOnlyForDeploymentPostprocessing = 0; 207 | }; 208 | /* End PBXResourcesBuildPhase section */ 209 | 210 | /* Begin PBXSourcesBuildPhase section */ 211 | D4EF3F3E1B91399200A887B6 /* Sources */ = { 212 | isa = PBXSourcesBuildPhase; 213 | buildActionMask = 2147483647; 214 | files = ( 215 | D4EF3F4A1B91399200A887B6 /* ViewController.swift in Sources */, 216 | D4EF3F651B913A1700A887B6 /* JZAvatarNSImageView.swift in Sources */, 217 | D4EF3F481B91399200A887B6 /* AppDelegate.swift in Sources */, 218 | ); 219 | runOnlyForDeploymentPostprocessing = 0; 220 | }; 221 | D4EF3F501B91399200A887B6 /* Sources */ = { 222 | isa = PBXSourcesBuildPhase; 223 | buildActionMask = 2147483647; 224 | files = ( 225 | D4EF3F5B1B91399200A887B6 /* JZAvatarImageViewDemoTests.swift in Sources */, 226 | ); 227 | runOnlyForDeploymentPostprocessing = 0; 228 | }; 229 | /* End PBXSourcesBuildPhase section */ 230 | 231 | /* Begin PBXTargetDependency section */ 232 | D4EF3F561B91399200A887B6 /* PBXTargetDependency */ = { 233 | isa = PBXTargetDependency; 234 | target = D4EF3F411B91399200A887B6 /* JZAvatarImageViewDemo */; 235 | targetProxy = D4EF3F551B91399200A887B6 /* PBXContainerItemProxy */; 236 | }; 237 | /* End PBXTargetDependency section */ 238 | 239 | /* Begin PBXVariantGroup section */ 240 | D4EF3F4D1B91399200A887B6 /* Main.storyboard */ = { 241 | isa = PBXVariantGroup; 242 | children = ( 243 | D4EF3F4E1B91399200A887B6 /* Base */, 244 | ); 245 | name = Main.storyboard; 246 | sourceTree = ""; 247 | }; 248 | /* End PBXVariantGroup section */ 249 | 250 | /* Begin XCBuildConfiguration section */ 251 | D4EF3F5C1B91399200A887B6 /* Debug */ = { 252 | isa = XCBuildConfiguration; 253 | buildSettings = { 254 | ALWAYS_SEARCH_USER_PATHS = NO; 255 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 256 | CLANG_CXX_LIBRARY = "libc++"; 257 | CLANG_ENABLE_MODULES = YES; 258 | CLANG_ENABLE_OBJC_ARC = YES; 259 | CLANG_WARN_BOOL_CONVERSION = YES; 260 | CLANG_WARN_CONSTANT_CONVERSION = YES; 261 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 262 | CLANG_WARN_EMPTY_BODY = YES; 263 | CLANG_WARN_ENUM_CONVERSION = YES; 264 | CLANG_WARN_INT_CONVERSION = YES; 265 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 266 | CLANG_WARN_UNREACHABLE_CODE = YES; 267 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 268 | CODE_SIGN_IDENTITY = "-"; 269 | COPY_PHASE_STRIP = NO; 270 | DEBUG_INFORMATION_FORMAT = dwarf; 271 | ENABLE_STRICT_OBJC_MSGSEND = YES; 272 | GCC_C_LANGUAGE_STANDARD = gnu99; 273 | GCC_DYNAMIC_NO_PIC = NO; 274 | GCC_NO_COMMON_BLOCKS = YES; 275 | GCC_OPTIMIZATION_LEVEL = 0; 276 | GCC_PREPROCESSOR_DEFINITIONS = ( 277 | "DEBUG=1", 278 | "$(inherited)", 279 | ); 280 | GCC_SYMBOLS_PRIVATE_EXTERN = NO; 281 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 282 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 283 | GCC_WARN_UNDECLARED_SELECTOR = YES; 284 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 285 | GCC_WARN_UNUSED_FUNCTION = YES; 286 | GCC_WARN_UNUSED_VARIABLE = YES; 287 | MACOSX_DEPLOYMENT_TARGET = 10.10; 288 | MTL_ENABLE_DEBUG_INFO = YES; 289 | ONLY_ACTIVE_ARCH = YES; 290 | SDKROOT = macosx; 291 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 292 | }; 293 | name = Debug; 294 | }; 295 | D4EF3F5D1B91399200A887B6 /* Release */ = { 296 | isa = XCBuildConfiguration; 297 | buildSettings = { 298 | ALWAYS_SEARCH_USER_PATHS = NO; 299 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 300 | CLANG_CXX_LIBRARY = "libc++"; 301 | CLANG_ENABLE_MODULES = YES; 302 | CLANG_ENABLE_OBJC_ARC = YES; 303 | CLANG_WARN_BOOL_CONVERSION = YES; 304 | CLANG_WARN_CONSTANT_CONVERSION = YES; 305 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 306 | CLANG_WARN_EMPTY_BODY = YES; 307 | CLANG_WARN_ENUM_CONVERSION = YES; 308 | CLANG_WARN_INT_CONVERSION = YES; 309 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 310 | CLANG_WARN_UNREACHABLE_CODE = YES; 311 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 312 | CODE_SIGN_IDENTITY = "-"; 313 | COPY_PHASE_STRIP = NO; 314 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 315 | ENABLE_NS_ASSERTIONS = NO; 316 | ENABLE_STRICT_OBJC_MSGSEND = YES; 317 | GCC_C_LANGUAGE_STANDARD = gnu99; 318 | GCC_NO_COMMON_BLOCKS = YES; 319 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 320 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 321 | GCC_WARN_UNDECLARED_SELECTOR = YES; 322 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 323 | GCC_WARN_UNUSED_FUNCTION = YES; 324 | GCC_WARN_UNUSED_VARIABLE = YES; 325 | MACOSX_DEPLOYMENT_TARGET = 10.10; 326 | MTL_ENABLE_DEBUG_INFO = NO; 327 | SDKROOT = macosx; 328 | }; 329 | name = Release; 330 | }; 331 | D4EF3F5F1B91399200A887B6 /* Debug */ = { 332 | isa = XCBuildConfiguration; 333 | buildSettings = { 334 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 335 | COMBINE_HIDPI_IMAGES = YES; 336 | INFOPLIST_FILE = JZAvatarImageViewDemo/Info.plist; 337 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks"; 338 | PRODUCT_NAME = "$(TARGET_NAME)"; 339 | }; 340 | name = Debug; 341 | }; 342 | D4EF3F601B91399200A887B6 /* Release */ = { 343 | isa = XCBuildConfiguration; 344 | buildSettings = { 345 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 346 | COMBINE_HIDPI_IMAGES = YES; 347 | INFOPLIST_FILE = JZAvatarImageViewDemo/Info.plist; 348 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks"; 349 | PRODUCT_NAME = "$(TARGET_NAME)"; 350 | }; 351 | name = Release; 352 | }; 353 | D4EF3F621B91399200A887B6 /* Debug */ = { 354 | isa = XCBuildConfiguration; 355 | buildSettings = { 356 | BUNDLE_LOADER = "$(TEST_HOST)"; 357 | COMBINE_HIDPI_IMAGES = YES; 358 | FRAMEWORK_SEARCH_PATHS = ( 359 | "$(DEVELOPER_FRAMEWORKS_DIR)", 360 | "$(inherited)", 361 | ); 362 | GCC_PREPROCESSOR_DEFINITIONS = ( 363 | "DEBUG=1", 364 | "$(inherited)", 365 | ); 366 | INFOPLIST_FILE = JZAvatarImageViewDemoTests/Info.plist; 367 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks"; 368 | PRODUCT_NAME = "$(TARGET_NAME)"; 369 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/JZAvatarImageViewDemo.app/Contents/MacOS/JZAvatarImageViewDemo"; 370 | }; 371 | name = Debug; 372 | }; 373 | D4EF3F631B91399200A887B6 /* Release */ = { 374 | isa = XCBuildConfiguration; 375 | buildSettings = { 376 | BUNDLE_LOADER = "$(TEST_HOST)"; 377 | COMBINE_HIDPI_IMAGES = YES; 378 | FRAMEWORK_SEARCH_PATHS = ( 379 | "$(DEVELOPER_FRAMEWORKS_DIR)", 380 | "$(inherited)", 381 | ); 382 | INFOPLIST_FILE = JZAvatarImageViewDemoTests/Info.plist; 383 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks"; 384 | PRODUCT_NAME = "$(TARGET_NAME)"; 385 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/JZAvatarImageViewDemo.app/Contents/MacOS/JZAvatarImageViewDemo"; 386 | }; 387 | name = Release; 388 | }; 389 | /* End XCBuildConfiguration section */ 390 | 391 | /* Begin XCConfigurationList section */ 392 | D4EF3F3D1B91399200A887B6 /* Build configuration list for PBXProject "JZAvatarImageViewDemo" */ = { 393 | isa = XCConfigurationList; 394 | buildConfigurations = ( 395 | D4EF3F5C1B91399200A887B6 /* Debug */, 396 | D4EF3F5D1B91399200A887B6 /* Release */, 397 | ); 398 | defaultConfigurationIsVisible = 0; 399 | defaultConfigurationName = Release; 400 | }; 401 | D4EF3F5E1B91399200A887B6 /* Build configuration list for PBXNativeTarget "JZAvatarImageViewDemo" */ = { 402 | isa = XCConfigurationList; 403 | buildConfigurations = ( 404 | D4EF3F5F1B91399200A887B6 /* Debug */, 405 | D4EF3F601B91399200A887B6 /* Release */, 406 | ); 407 | defaultConfigurationIsVisible = 0; 408 | defaultConfigurationName = Release; 409 | }; 410 | D4EF3F611B91399200A887B6 /* Build configuration list for PBXNativeTarget "JZAvatarImageViewDemoTests" */ = { 411 | isa = XCConfigurationList; 412 | buildConfigurations = ( 413 | D4EF3F621B91399200A887B6 /* Debug */, 414 | D4EF3F631B91399200A887B6 /* Release */, 415 | ); 416 | defaultConfigurationIsVisible = 0; 417 | defaultConfigurationName = Release; 418 | }; 419 | /* End XCConfigurationList section */ 420 | }; 421 | rootObject = D4EF3F3A1B91399200A887B6 /* Project object */; 422 | } 423 | -------------------------------------------------------------------------------- /Demo/JZAvatarImageViewDemo/JZAvatarImageViewDemo.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Demo/JZAvatarImageViewDemo/JZAvatarImageViewDemo/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.swift 3 | // JZAvatarImageViewDemo 4 | // 5 | // Created by Joey on 8/28/15. 6 | // Copyright (c) 2015 Joey. All rights reserved. 7 | // 8 | 9 | import Cocoa 10 | 11 | @NSApplicationMain 12 | class AppDelegate: NSObject, NSApplicationDelegate { 13 | 14 | 15 | 16 | func applicationDidFinishLaunching(aNotification: NSNotification) { 17 | // Insert code here to initialize your application 18 | } 19 | 20 | func applicationWillTerminate(aNotification: NSNotification) { 21 | // Insert code here to tear down your application 22 | } 23 | 24 | 25 | } 26 | 27 | -------------------------------------------------------------------------------- /Demo/JZAvatarImageViewDemo/JZAvatarImageViewDemo/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 | 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 | Default 510 | 511 | 512 | 513 | 514 | 515 | 516 | Left to Right 517 | 518 | 519 | 520 | 521 | 522 | 523 | Right to Left 524 | 525 | 526 | 527 | 528 | 529 | 530 | 531 | 532 | 533 | 534 | Default 535 | 536 | 537 | 538 | 539 | 540 | 541 | Left to Right 542 | 543 | 544 | 545 | 546 | 547 | 548 | Right to Left 549 | 550 | 551 | 552 | 553 | 554 | 555 | 556 | 557 | 558 | 559 | 560 | 561 | 562 | 563 | 564 | 565 | 566 | 567 | 568 | 569 | 570 | 571 | 572 | 573 | 574 | 575 | 576 | 577 | 578 | 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 | 680 | 681 | 682 | 683 | 684 | 685 | 686 | 687 | 688 | 689 | 690 | 691 | 692 | 693 | 694 | 695 | 696 | 697 | 698 | 699 | 700 | 701 | 702 | 703 | 704 | 705 | 706 | 707 | 708 | 709 | 710 | 711 | 712 | 713 | 714 | 715 | -------------------------------------------------------------------------------- /Demo/JZAvatarImageViewDemo/JZAvatarImageViewDemo/Images.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 | } -------------------------------------------------------------------------------- /Demo/JZAvatarImageViewDemo/JZAvatarImageViewDemo/Images.xcassets/waz.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "scale" : "1x", 6 | "filename" : "waz.jpg" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "scale" : "3x" 15 | } 16 | ], 17 | "info" : { 18 | "version" : 1, 19 | "author" : "xcode" 20 | } 21 | } -------------------------------------------------------------------------------- /Demo/JZAvatarImageViewDemo/JZAvatarImageViewDemo/Images.xcassets/waz.imageset/waz.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Swift-Kit/JZAvatarNSImageView/5a6a51153c66823fc6d546fd7ffd8b27e37d7baa/Demo/JZAvatarImageViewDemo/JZAvatarImageViewDemo/Images.xcassets/waz.imageset/waz.jpg -------------------------------------------------------------------------------- /Demo/JZAvatarImageViewDemo/JZAvatarImageViewDemo/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIconFile 10 | 11 | CFBundleIdentifier 12 | com.joeyzhou.$(PRODUCT_NAME:rfc1034identifier) 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 © 2015 Joey. All rights reserved. 29 | NSMainStoryboardFile 30 | Main 31 | NSPrincipalClass 32 | NSApplication 33 | 34 | 35 | -------------------------------------------------------------------------------- /Demo/JZAvatarImageViewDemo/JZAvatarImageViewDemo/ViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.swift 3 | // JZAvatarImageViewDemo 4 | // 5 | // Created by Joey on 8/28/15. 6 | // Copyright (c) 2015 Joey. All rights reserved. 7 | // 8 | 9 | import Cocoa 10 | 11 | class ViewController: NSViewController { 12 | 13 | @IBOutlet weak var userImageView: JZAvatarNSImageView! 14 | @IBOutlet weak var wozImageView: JZAvatarNSImageView! 15 | 16 | override func viewDidLoad() { 17 | super.viewDidLoad() 18 | 19 | // default setting, draw it 20 | userImageView.redraw() 21 | 22 | wozImageView.borderColor = NSColor.orangeColor() 23 | wozImageView.borderWidth = 3.0 24 | wozImageView.redraw() 25 | 26 | // Do any additional setup after loading the view. 27 | } 28 | 29 | override var representedObject: AnyObject? { 30 | didSet { 31 | // Update the view, if already loaded. 32 | } 33 | } 34 | 35 | 36 | } 37 | 38 | -------------------------------------------------------------------------------- /Demo/JZAvatarImageViewDemo/JZAvatarImageViewDemoTests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | com.joeyzhou.$(PRODUCT_NAME:rfc1034identifier) 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 | -------------------------------------------------------------------------------- /Demo/JZAvatarImageViewDemo/JZAvatarImageViewDemoTests/JZAvatarImageViewDemoTests.swift: -------------------------------------------------------------------------------- 1 | // 2 | // JZAvatarImageViewDemoTests.swift 3 | // JZAvatarImageViewDemoTests 4 | // 5 | // Created by Joey on 8/28/15. 6 | // Copyright (c) 2015 Joey. All rights reserved. 7 | // 8 | 9 | import Cocoa 10 | import XCTest 11 | 12 | class JZAvatarImageViewDemoTests: 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.measureBlock() { 32 | // Put the code you want to measure the time of here. 33 | } 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /JZAvatarNSImageView.swift: -------------------------------------------------------------------------------- 1 | // 2 | // JZAvatarNSImageView.swift 3 | // 4 | // Created by Joey Zhou on 8/28/15. 5 | // Copyright (c) 2015 Joey Zhou. All rights reserved. 6 | // 7 | 8 | import Cocoa 9 | import AppKit 10 | 11 | class JZAvatarNSImageView: NSImageView { 12 | 13 | var cornerRadius: CGFloat = 0.0 14 | var borderWidth: CGFloat = 1.0 15 | var borderColor: NSColor 16 | 17 | override init(frame frameRect: NSRect) { 18 | borderColor = NSColor.grayColor() 19 | super.init(frame: frameRect) 20 | cornerRadius = frame.height/2.0 21 | } 22 | 23 | required init?(coder: NSCoder) { 24 | borderWidth = 1.0; 25 | borderColor = NSColor.grayColor() 26 | super.init(coder: coder) 27 | cornerRadius = frame.height/2.0 28 | 29 | } 30 | 31 | convenience init?(f: NSRect, bc: NSColor, bw: CGFloat) { 32 | self.init(frame: f) 33 | borderColor = bc 34 | borderWidth = bw 35 | redraw() 36 | } 37 | 38 | convenience init?(f: NSRect, i: NSImage, bc: NSColor, bw: CGFloat) { 39 | self.init(frame: f) 40 | borderColor = bc 41 | borderWidth = bw 42 | image = i 43 | redraw() 44 | } 45 | 46 | override func drawRect(dirtyRect: NSRect) { 47 | super.drawRect(dirtyRect) 48 | } 49 | 50 | func redraw() { 51 | if (frame.width != frame.height) { 52 | self.print("Warning: Height and Width should be the same for image view"); 53 | } 54 | 55 | self.wantsLayer = true 56 | layer?.borderWidth = borderWidth 57 | layer?.borderColor = borderColor.CGColor 58 | layer?.cornerRadius = cornerRadius 59 | 60 | } 61 | 62 | } -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015 Joe Zhou 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 | 23 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # JZAvatarNSImageView 2 | Subclass of NSImageView, circular avatar image view. Currently support up to Swift 2.0. 3 | 4 | [![screenshot](https://github.com/josephyzhou/JZAvatarNSImageView/raw/master/screenshot/screenshot.png)](https://github.com/josephyzhou/JZAvatarNSImageView/raw/master/screenshot/screenshot.png) 5 | ## Usage 6 | Drag `JZAvatarNSImageView.swift` to your project 7 | 8 | Either init with one of the initializer or create via Interface Builder and set the class of NSImageView as JZAvatarNSImageView 9 | 10 | You can change the color/width of the border by simply doing: 11 | 12 | ``` 13 | imageView.borderColor = NSColor.blackColor() 14 | imageView.borderWidth = 2.0 15 | ``` 16 | 17 | ## License 18 | MIT, see license file -------------------------------------------------------------------------------- /screenshot/screenshot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Swift-Kit/JZAvatarNSImageView/5a6a51153c66823fc6d546fd7ffd8b27e37d7baa/screenshot/screenshot.png --------------------------------------------------------------------------------