├── HoverButtonDemo.xcodeproj ├── project.pbxproj ├── project.xcworkspace │ ├── contents.xcworkspacedata │ └── xcuserdata │ │ └── lindahai.xcuserdatad │ │ └── UserInterfaceState.xcuserstate └── xcuserdata │ └── lindahai.xcuserdatad │ ├── xcdebugger │ └── Breakpoints_v2.xcbkptlist │ └── xcschemes │ ├── HoverButtonDemo.xcscheme │ └── xcschememanagement.plist ├── HoverButtonDemo ├── AppDelegate.swift ├── Assets.xcassets │ └── AppIcon.appiconset │ │ └── Contents.json ├── Base.lproj │ └── MainMenu.xib ├── HoverButton.swift ├── Info.plist ├── LoginButton.swift └── images │ ├── facebook.png │ ├── google.png │ ├── instagram.png │ └── twitter.png └── README.md /HoverButtonDemo.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | F15710051C4FC0CB002663E3 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = F15710041C4FC0CB002663E3 /* AppDelegate.swift */; }; 11 | F15710071C4FC0CB002663E3 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = F15710061C4FC0CB002663E3 /* Assets.xcassets */; }; 12 | F157100A1C4FC0CB002663E3 /* MainMenu.xib in Resources */ = {isa = PBXBuildFile; fileRef = F15710081C4FC0CB002663E3 /* MainMenu.xib */; }; 13 | F15710131C4FC139002663E3 /* HoverButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = F15710121C4FC139002663E3 /* HoverButton.swift */; }; 14 | F18BBCF81C534A0000E78791 /* facebook.png in Resources */ = {isa = PBXBuildFile; fileRef = F18BBCF31C534A0000E78791 /* facebook.png */; }; 15 | F18BBCF91C534A0000E78791 /* google.png in Resources */ = {isa = PBXBuildFile; fileRef = F18BBCF41C534A0000E78791 /* google.png */; }; 16 | F18BBCFA1C534A0000E78791 /* instagram.png in Resources */ = {isa = PBXBuildFile; fileRef = F18BBCF51C534A0000E78791 /* instagram.png */; }; 17 | F18BBCFB1C534A0000E78791 /* twitter.png in Resources */ = {isa = PBXBuildFile; fileRef = F18BBCF61C534A0000E78791 /* twitter.png */; }; 18 | F1A00F8E1C5B539900DD1C10 /* LoginButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = F1A00F8D1C5B539900DD1C10 /* LoginButton.swift */; }; 19 | /* End PBXBuildFile section */ 20 | 21 | /* Begin PBXFileReference section */ 22 | F15710011C4FC0CB002663E3 /* HoverButtonDemo.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = HoverButtonDemo.app; sourceTree = BUILT_PRODUCTS_DIR; }; 23 | F15710041C4FC0CB002663E3 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 24 | F15710061C4FC0CB002663E3 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; name = Assets.xcassets; path = HoverButtonDemo/Assets.xcassets; sourceTree = ""; }; 25 | F15710091C4FC0CB002663E3 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Base.lproj/MainMenu.xib; sourceTree = ""; }; 26 | F157100B1C4FC0CB002663E3 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; name = Info.plist; path = HoverButtonDemo/Info.plist; sourceTree = ""; }; 27 | F15710121C4FC139002663E3 /* HoverButton.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = HoverButton.swift; sourceTree = ""; }; 28 | F18BBCF31C534A0000E78791 /* facebook.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = facebook.png; sourceTree = ""; }; 29 | F18BBCF41C534A0000E78791 /* google.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = google.png; sourceTree = ""; }; 30 | F18BBCF51C534A0000E78791 /* instagram.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = instagram.png; sourceTree = ""; }; 31 | F18BBCF61C534A0000E78791 /* twitter.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = twitter.png; sourceTree = ""; }; 32 | F1A00F8D1C5B539900DD1C10 /* LoginButton.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = LoginButton.swift; sourceTree = ""; }; 33 | /* End PBXFileReference section */ 34 | 35 | /* Begin PBXFrameworksBuildPhase section */ 36 | F1570FFE1C4FC0CB002663E3 /* Frameworks */ = { 37 | isa = PBXFrameworksBuildPhase; 38 | buildActionMask = 2147483647; 39 | files = ( 40 | ); 41 | runOnlyForDeploymentPostprocessing = 0; 42 | }; 43 | /* End PBXFrameworksBuildPhase section */ 44 | 45 | /* Begin PBXGroup section */ 46 | F1570FF81C4FC0CB002663E3 = { 47 | isa = PBXGroup; 48 | children = ( 49 | F15710031C4FC0CB002663E3 /* HoverButtonDemo */, 50 | F15710021C4FC0CB002663E3 /* Products */, 51 | ); 52 | sourceTree = ""; 53 | }; 54 | F15710021C4FC0CB002663E3 /* Products */ = { 55 | isa = PBXGroup; 56 | children = ( 57 | F15710011C4FC0CB002663E3 /* HoverButtonDemo.app */, 58 | ); 59 | name = Products; 60 | sourceTree = ""; 61 | }; 62 | F15710031C4FC0CB002663E3 /* HoverButtonDemo */ = { 63 | isa = PBXGroup; 64 | children = ( 65 | F1A00F8D1C5B539900DD1C10 /* LoginButton.swift */, 66 | F15710041C4FC0CB002663E3 /* AppDelegate.swift */, 67 | F15710121C4FC139002663E3 /* HoverButton.swift */, 68 | F15710081C4FC0CB002663E3 /* MainMenu.xib */, 69 | F18BBCFD1C53524B00E78791 /* Supporting Files */, 70 | F18BBCF11C534A0000E78791 /* images */, 71 | ); 72 | path = HoverButtonDemo; 73 | sourceTree = ""; 74 | }; 75 | F18BBCF11C534A0000E78791 /* images */ = { 76 | isa = PBXGroup; 77 | children = ( 78 | F18BBCF31C534A0000E78791 /* facebook.png */, 79 | F18BBCF41C534A0000E78791 /* google.png */, 80 | F18BBCF51C534A0000E78791 /* instagram.png */, 81 | F18BBCF61C534A0000E78791 /* twitter.png */, 82 | ); 83 | path = images; 84 | sourceTree = ""; 85 | }; 86 | F18BBCFD1C53524B00E78791 /* Supporting Files */ = { 87 | isa = PBXGroup; 88 | children = ( 89 | F157100B1C4FC0CB002663E3 /* Info.plist */, 90 | F15710061C4FC0CB002663E3 /* Assets.xcassets */, 91 | ); 92 | name = "Supporting Files"; 93 | path = ..; 94 | sourceTree = ""; 95 | }; 96 | /* End PBXGroup section */ 97 | 98 | /* Begin PBXNativeTarget section */ 99 | F15710001C4FC0CB002663E3 /* HoverButtonDemo */ = { 100 | isa = PBXNativeTarget; 101 | buildConfigurationList = F157100E1C4FC0CB002663E3 /* Build configuration list for PBXNativeTarget "HoverButtonDemo" */; 102 | buildPhases = ( 103 | F1570FFD1C4FC0CB002663E3 /* Sources */, 104 | F1570FFE1C4FC0CB002663E3 /* Frameworks */, 105 | F1570FFF1C4FC0CB002663E3 /* Resources */, 106 | ); 107 | buildRules = ( 108 | ); 109 | dependencies = ( 110 | ); 111 | name = HoverButtonDemo; 112 | productName = HoverButtonDemo; 113 | productReference = F15710011C4FC0CB002663E3 /* HoverButtonDemo.app */; 114 | productType = "com.apple.product-type.application"; 115 | }; 116 | /* End PBXNativeTarget section */ 117 | 118 | /* Begin PBXProject section */ 119 | F1570FF91C4FC0CB002663E3 /* Project object */ = { 120 | isa = PBXProject; 121 | attributes = { 122 | LastSwiftUpdateCheck = 0710; 123 | LastUpgradeCheck = 0710; 124 | ORGANIZATIONNAME = fancy; 125 | TargetAttributes = { 126 | F15710001C4FC0CB002663E3 = { 127 | CreatedOnToolsVersion = 7.1.1; 128 | LastSwiftMigration = 0800; 129 | }; 130 | }; 131 | }; 132 | buildConfigurationList = F1570FFC1C4FC0CB002663E3 /* Build configuration list for PBXProject "HoverButtonDemo" */; 133 | compatibilityVersion = "Xcode 3.2"; 134 | developmentRegion = English; 135 | hasScannedForEncodings = 0; 136 | knownRegions = ( 137 | en, 138 | Base, 139 | ); 140 | mainGroup = F1570FF81C4FC0CB002663E3; 141 | productRefGroup = F15710021C4FC0CB002663E3 /* Products */; 142 | projectDirPath = ""; 143 | projectRoot = ""; 144 | targets = ( 145 | F15710001C4FC0CB002663E3 /* HoverButtonDemo */, 146 | ); 147 | }; 148 | /* End PBXProject section */ 149 | 150 | /* Begin PBXResourcesBuildPhase section */ 151 | F1570FFF1C4FC0CB002663E3 /* Resources */ = { 152 | isa = PBXResourcesBuildPhase; 153 | buildActionMask = 2147483647; 154 | files = ( 155 | F18BBCFB1C534A0000E78791 /* twitter.png in Resources */, 156 | F18BBCFA1C534A0000E78791 /* instagram.png in Resources */, 157 | F15710071C4FC0CB002663E3 /* Assets.xcassets in Resources */, 158 | F18BBCF81C534A0000E78791 /* facebook.png in Resources */, 159 | F157100A1C4FC0CB002663E3 /* MainMenu.xib in Resources */, 160 | F18BBCF91C534A0000E78791 /* google.png in Resources */, 161 | ); 162 | runOnlyForDeploymentPostprocessing = 0; 163 | }; 164 | /* End PBXResourcesBuildPhase section */ 165 | 166 | /* Begin PBXSourcesBuildPhase section */ 167 | F1570FFD1C4FC0CB002663E3 /* Sources */ = { 168 | isa = PBXSourcesBuildPhase; 169 | buildActionMask = 2147483647; 170 | files = ( 171 | F15710131C4FC139002663E3 /* HoverButton.swift in Sources */, 172 | F1A00F8E1C5B539900DD1C10 /* LoginButton.swift in Sources */, 173 | F15710051C4FC0CB002663E3 /* AppDelegate.swift in Sources */, 174 | ); 175 | runOnlyForDeploymentPostprocessing = 0; 176 | }; 177 | /* End PBXSourcesBuildPhase section */ 178 | 179 | /* Begin PBXVariantGroup section */ 180 | F15710081C4FC0CB002663E3 /* MainMenu.xib */ = { 181 | isa = PBXVariantGroup; 182 | children = ( 183 | F15710091C4FC0CB002663E3 /* Base */, 184 | ); 185 | name = MainMenu.xib; 186 | sourceTree = ""; 187 | }; 188 | /* End PBXVariantGroup section */ 189 | 190 | /* Begin XCBuildConfiguration section */ 191 | F157100C1C4FC0CB002663E3 /* Debug */ = { 192 | isa = XCBuildConfiguration; 193 | buildSettings = { 194 | ALWAYS_SEARCH_USER_PATHS = NO; 195 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 196 | CLANG_CXX_LIBRARY = "libc++"; 197 | CLANG_ENABLE_MODULES = YES; 198 | CLANG_ENABLE_OBJC_ARC = YES; 199 | CLANG_WARN_BOOL_CONVERSION = YES; 200 | CLANG_WARN_CONSTANT_CONVERSION = YES; 201 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 202 | CLANG_WARN_EMPTY_BODY = YES; 203 | CLANG_WARN_ENUM_CONVERSION = YES; 204 | CLANG_WARN_INT_CONVERSION = YES; 205 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 206 | CLANG_WARN_UNREACHABLE_CODE = YES; 207 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 208 | CODE_SIGN_IDENTITY = "-"; 209 | COPY_PHASE_STRIP = NO; 210 | DEBUG_INFORMATION_FORMAT = dwarf; 211 | ENABLE_STRICT_OBJC_MSGSEND = YES; 212 | ENABLE_TESTABILITY = YES; 213 | GCC_C_LANGUAGE_STANDARD = gnu99; 214 | GCC_DYNAMIC_NO_PIC = NO; 215 | GCC_NO_COMMON_BLOCKS = YES; 216 | GCC_OPTIMIZATION_LEVEL = 0; 217 | GCC_PREPROCESSOR_DEFINITIONS = ( 218 | "DEBUG=1", 219 | "$(inherited)", 220 | ); 221 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 222 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 223 | GCC_WARN_UNDECLARED_SELECTOR = YES; 224 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 225 | GCC_WARN_UNUSED_FUNCTION = YES; 226 | GCC_WARN_UNUSED_VARIABLE = YES; 227 | MACOSX_DEPLOYMENT_TARGET = 10.11; 228 | MTL_ENABLE_DEBUG_INFO = YES; 229 | ONLY_ACTIVE_ARCH = YES; 230 | SDKROOT = macosx; 231 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 232 | }; 233 | name = Debug; 234 | }; 235 | F157100D1C4FC0CB002663E3 /* Release */ = { 236 | isa = XCBuildConfiguration; 237 | buildSettings = { 238 | ALWAYS_SEARCH_USER_PATHS = NO; 239 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 240 | CLANG_CXX_LIBRARY = "libc++"; 241 | CLANG_ENABLE_MODULES = YES; 242 | CLANG_ENABLE_OBJC_ARC = YES; 243 | CLANG_WARN_BOOL_CONVERSION = YES; 244 | CLANG_WARN_CONSTANT_CONVERSION = YES; 245 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 246 | CLANG_WARN_EMPTY_BODY = YES; 247 | CLANG_WARN_ENUM_CONVERSION = YES; 248 | CLANG_WARN_INT_CONVERSION = YES; 249 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 250 | CLANG_WARN_UNREACHABLE_CODE = YES; 251 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 252 | CODE_SIGN_IDENTITY = "-"; 253 | COPY_PHASE_STRIP = NO; 254 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 255 | ENABLE_NS_ASSERTIONS = NO; 256 | ENABLE_STRICT_OBJC_MSGSEND = YES; 257 | GCC_C_LANGUAGE_STANDARD = gnu99; 258 | GCC_NO_COMMON_BLOCKS = YES; 259 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 260 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 261 | GCC_WARN_UNDECLARED_SELECTOR = YES; 262 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 263 | GCC_WARN_UNUSED_FUNCTION = YES; 264 | GCC_WARN_UNUSED_VARIABLE = YES; 265 | MACOSX_DEPLOYMENT_TARGET = 10.11; 266 | MTL_ENABLE_DEBUG_INFO = NO; 267 | SDKROOT = macosx; 268 | }; 269 | name = Release; 270 | }; 271 | F157100F1C4FC0CB002663E3 /* Debug */ = { 272 | isa = XCBuildConfiguration; 273 | buildSettings = { 274 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 275 | COMBINE_HIDPI_IMAGES = YES; 276 | INFOPLIST_FILE = HoverButtonDemo/Info.plist; 277 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks"; 278 | PRODUCT_BUNDLE_IDENTIFIER = fancymax.HoverButtonDemo; 279 | PRODUCT_NAME = "$(TARGET_NAME)"; 280 | SWIFT_VERSION = 3.0; 281 | }; 282 | name = Debug; 283 | }; 284 | F15710101C4FC0CB002663E3 /* Release */ = { 285 | isa = XCBuildConfiguration; 286 | buildSettings = { 287 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 288 | COMBINE_HIDPI_IMAGES = YES; 289 | INFOPLIST_FILE = HoverButtonDemo/Info.plist; 290 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks"; 291 | PRODUCT_BUNDLE_IDENTIFIER = fancymax.HoverButtonDemo; 292 | PRODUCT_NAME = "$(TARGET_NAME)"; 293 | SWIFT_VERSION = 3.0; 294 | }; 295 | name = Release; 296 | }; 297 | /* End XCBuildConfiguration section */ 298 | 299 | /* Begin XCConfigurationList section */ 300 | F1570FFC1C4FC0CB002663E3 /* Build configuration list for PBXProject "HoverButtonDemo" */ = { 301 | isa = XCConfigurationList; 302 | buildConfigurations = ( 303 | F157100C1C4FC0CB002663E3 /* Debug */, 304 | F157100D1C4FC0CB002663E3 /* Release */, 305 | ); 306 | defaultConfigurationIsVisible = 0; 307 | defaultConfigurationName = Release; 308 | }; 309 | F157100E1C4FC0CB002663E3 /* Build configuration list for PBXNativeTarget "HoverButtonDemo" */ = { 310 | isa = XCConfigurationList; 311 | buildConfigurations = ( 312 | F157100F1C4FC0CB002663E3 /* Debug */, 313 | F15710101C4FC0CB002663E3 /* Release */, 314 | ); 315 | defaultConfigurationIsVisible = 0; 316 | defaultConfigurationName = Release; 317 | }; 318 | /* End XCConfigurationList section */ 319 | }; 320 | rootObject = F1570FF91C4FC0CB002663E3 /* Project object */; 321 | } 322 | -------------------------------------------------------------------------------- /HoverButtonDemo.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /HoverButtonDemo.xcodeproj/project.xcworkspace/xcuserdata/lindahai.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fancymax/HoverButton/88856f3436ef62daee4bbe82da21e3dbf52199f9/HoverButtonDemo.xcodeproj/project.xcworkspace/xcuserdata/lindahai.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /HoverButtonDemo.xcodeproj/xcuserdata/lindahai.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | -------------------------------------------------------------------------------- /HoverButtonDemo.xcodeproj/xcuserdata/lindahai.xcuserdatad/xcschemes/HoverButtonDemo.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 32 | 33 | 39 | 40 | 41 | 42 | 43 | 44 | 54 | 56 | 62 | 63 | 64 | 65 | 66 | 67 | 73 | 75 | 81 | 82 | 83 | 84 | 86 | 87 | 90 | 91 | 92 | -------------------------------------------------------------------------------- /HoverButtonDemo.xcodeproj/xcuserdata/lindahai.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | HoverButtonDemo.xcscheme 8 | 9 | orderHint 10 | 0 11 | 12 | 13 | SuppressBuildableAutocreation 14 | 15 | F15710001C4FC0CB002663E3 16 | 17 | primary 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /HoverButtonDemo/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.swift 3 | // HoverButtonDemo 4 | // 5 | // Created by fancymax on 16/1/20. 6 | // Copyright © 2016年 fancy. All rights reserved. 7 | // 8 | 9 | import Cocoa 10 | 11 | @NSApplicationMain 12 | class AppDelegate: NSObject, NSApplicationDelegate { 13 | 14 | @IBOutlet weak var window: NSWindow! 15 | 16 | 17 | @IBOutlet weak var testBtn: HoverButton! 18 | func applicationDidFinishLaunching(_ aNotification: Notification) { 19 | // Insert code here to initialize your application 20 | 21 | let attrs = [NSForegroundColorAttributeName: NSColor.blue] 22 | testBtn.attributedStringValue = NSAttributedString(string: testBtn.stringValue, attributes: attrs) 23 | 24 | } 25 | 26 | func applicationWillTerminate(_ aNotification: Notification) { 27 | // Insert code here to tear down your application 28 | } 29 | 30 | 31 | } 32 | 33 | -------------------------------------------------------------------------------- /HoverButtonDemo/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 | } -------------------------------------------------------------------------------- /HoverButtonDemo/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 | 540 | Default 541 | 542 | 543 | 544 | 545 | 546 | 547 | Left to Right 548 | 549 | 550 | 551 | 552 | 553 | 554 | Right to Left 555 | 556 | 557 | 558 | 559 | 560 | 561 | 562 | 563 | 564 | 565 | Default 566 | 567 | 568 | 569 | 570 | 571 | 572 | Left to Right 573 | 574 | 575 | 576 | 577 | 578 | 579 | Right to Left 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 | 689 | 705 | 721 | 737 | 753 | 761 | 762 | 763 | 764 | 765 | 766 | 767 | 768 | 769 | 770 | 771 | 772 | 773 | 774 | -------------------------------------------------------------------------------- /HoverButtonDemo/HoverButton.swift: -------------------------------------------------------------------------------- 1 | // 2 | // HoverButton.swift 3 | // HoverButtonDemo 4 | // 5 | // Created by fancymax on 16/1/20. 6 | // Copyright © 2016年 fancy. All rights reserved. 7 | // 8 | 9 | import Cocoa 10 | 11 | class HoverButton: NSButton{ 12 | var backgroundColor: NSColor? 13 | var hoveredBackgroundColor: NSColor? 14 | var pressedBackgroundColor: NSColor? 15 | 16 | fileprivate var hovered: Bool = false 17 | 18 | override var wantsUpdateLayer:Bool{ 19 | return true 20 | } 21 | 22 | required init?(coder: NSCoder) { 23 | super.init(coder: coder) 24 | self.commonInit() 25 | } 26 | 27 | override init(frame frameRect: NSRect) { 28 | super.init(frame: frameRect) 29 | self.commonInit() 30 | } 31 | 32 | func commonInit(){ 33 | self.wantsLayer = true 34 | self.createTrackingArea() 35 | self.hovered = false 36 | self.hoveredBackgroundColor = NSColor.selectedTextBackgroundColor 37 | self.pressedBackgroundColor = NSColor.selectedTextBackgroundColor 38 | self.backgroundColor = NSColor.clear 39 | 40 | } 41 | 42 | fileprivate var trackingArea: NSTrackingArea! 43 | func createTrackingArea(){ 44 | if(self.trackingArea != nil){ 45 | self.removeTrackingArea(self.trackingArea!) 46 | } 47 | let circleRect = self.bounds 48 | let flag = NSTrackingAreaOptions.mouseEnteredAndExited.rawValue + NSTrackingAreaOptions.activeInActiveApp.rawValue 49 | self.trackingArea = NSTrackingArea(rect: circleRect, options: NSTrackingAreaOptions(rawValue: flag), owner: self, userInfo: nil) 50 | self.addTrackingArea(self.trackingArea) 51 | } 52 | 53 | override func mouseEntered(with theEvent: NSEvent) { 54 | self.hovered = true 55 | self.needsDisplay = true 56 | } 57 | 58 | override func mouseExited(with theEvent: NSEvent) { 59 | self.hovered = false 60 | self.needsDisplay = true 61 | } 62 | 63 | override func updateLayer() { 64 | if(hovered){ 65 | if (self.cell!.isHighlighted){ 66 | self.layer?.cornerRadius = 15.0 67 | self.layer?.borderColor = pressedBackgroundColor?.cgColor 68 | self.layer?.borderWidth = 2 69 | 70 | } 71 | else{ 72 | self.layer?.cornerRadius = 15.0 73 | self.layer?.borderColor = hoveredBackgroundColor?.cgColor 74 | self.layer?.borderWidth = 2 75 | 76 | } 77 | } 78 | else{ 79 | self.layer?.backgroundColor = backgroundColor?.cgColor 80 | self.layer?.borderWidth = 0 81 | 82 | } 83 | 84 | } 85 | } 86 | -------------------------------------------------------------------------------- /HoverButtonDemo/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年 fancy. All rights reserved. 29 | NSMainNibFile 30 | MainMenu 31 | NSPrincipalClass 32 | NSApplication 33 | 34 | 35 | -------------------------------------------------------------------------------- /HoverButtonDemo/LoginButton.swift: -------------------------------------------------------------------------------- 1 | // 2 | // LoginButton.swift 3 | // HoverButtonDemo 4 | // 5 | // Created by fancymax on 16/1/29. 6 | // Copyright © 2016年 fancy. All rights reserved. 7 | // 8 | 9 | import Cocoa 10 | 11 | class LoginButton: NSButton{ 12 | fileprivate var hovered: Bool = false 13 | 14 | required init?(coder: NSCoder) { 15 | super.init(coder: coder) 16 | self.commonInit() 17 | } 18 | 19 | override init(frame frameRect: NSRect) { 20 | super.init(frame: frameRect) 21 | self.commonInit() 22 | } 23 | 24 | func commonInit(){ 25 | self.wantsLayer = true 26 | self.createTrackingArea() 27 | self.hovered = false 28 | 29 | 30 | } 31 | 32 | fileprivate var trackingArea: NSTrackingArea! 33 | func createTrackingArea(){ 34 | if(self.trackingArea != nil){ 35 | self.removeTrackingArea(self.trackingArea!) 36 | } 37 | let circleRect = self.bounds 38 | let flag = NSTrackingAreaOptions.mouseEnteredAndExited.rawValue + NSTrackingAreaOptions.activeInActiveApp.rawValue 39 | self.trackingArea = NSTrackingArea(rect: circleRect, options: NSTrackingAreaOptions(rawValue: flag), owner: self, userInfo: nil) 40 | self.addTrackingArea(self.trackingArea) 41 | } 42 | 43 | override func mouseEntered(with theEvent: NSEvent) { 44 | self.hovered = true 45 | self.needsDisplay = true 46 | } 47 | 48 | override func mouseExited(with theEvent: NSEvent) { 49 | self.hovered = false 50 | self.needsDisplay = true 51 | } 52 | 53 | func drawText(_ text:String, inRect:NSRect){ 54 | let aParagraghStyle = NSMutableParagraphStyle() 55 | aParagraghStyle.lineBreakMode = NSLineBreakMode.byWordWrapping 56 | aParagraghStyle.alignment = NSTextAlignment.left 57 | 58 | let attrs = [NSParagraphStyleAttributeName:aParagraghStyle, NSFontAttributeName:self.font!] as [String : Any] 59 | let size = (text as NSString).size(withAttributes: attrs) 60 | let r:NSRect = NSMakeRect(inRect.origin.x, 61 | inRect.origin.y + (inRect.size.height - size.height)/2.0 - 2, 62 | inRect.size.width, 63 | size.height) 64 | (text as NSString).draw(in: r, withAttributes: attrs) 65 | } 66 | 67 | override func draw(_ dirtyRect: NSRect) { 68 | NSGraphicsContext.saveGraphicsState() 69 | 70 | var imageRect = NSRect() 71 | if let image = self.image{ 72 | imageRect.size.height = self.bounds.height - 6 73 | imageRect.size.width = imageRect.size.height 74 | imageRect.origin.x = 3 75 | imageRect.origin.y = 3 76 | image.draw(in: imageRect) 77 | } 78 | var textRect = self.bounds 79 | textRect.origin.x += imageRect.size.width + 10 80 | textRect.origin.y += 1 81 | textRect.size.width -= imageRect.size.width + 5 82 | 83 | if (hovered){ 84 | var rect = self.bounds 85 | rect.size.height -= 2 86 | rect.size.width -= 2 87 | rect.origin.x += 1 88 | rect.origin.y += 1 89 | let bgPath = NSBezierPath(roundedRect: rect, xRadius: 5, yRadius: 5) 90 | NSColor.lightGray.set() 91 | bgPath.lineWidth = 1 92 | bgPath.stroke() 93 | } 94 | 95 | drawText(self.title + " ▾", inRect: textRect) 96 | 97 | NSGraphicsContext.restoreGraphicsState() 98 | } 99 | } 100 | -------------------------------------------------------------------------------- /HoverButtonDemo/images/facebook.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fancymax/HoverButton/88856f3436ef62daee4bbe82da21e3dbf52199f9/HoverButtonDemo/images/facebook.png -------------------------------------------------------------------------------- /HoverButtonDemo/images/google.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fancymax/HoverButton/88856f3436ef62daee4bbe82da21e3dbf52199f9/HoverButtonDemo/images/google.png -------------------------------------------------------------------------------- /HoverButtonDemo/images/instagram.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fancymax/HoverButton/88856f3436ef62daee4bbe82da21e3dbf52199f9/HoverButtonDemo/images/instagram.png -------------------------------------------------------------------------------- /HoverButtonDemo/images/twitter.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fancymax/HoverButton/88856f3436ef62daee4bbe82da21e3dbf52199f9/HoverButtonDemo/images/twitter.png -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # HoverButton 2 | HoverButton for OS X(Swift) 3 | 4 | # Demo 5 | Open the demo to figure out how to use HoverButton in your program. 6 | ![demo](http://7xpbra.com1.z0.glb.clouddn.com/HoverButtonDemo.gif) 7 | --------------------------------------------------------------------------------