26 Commits

Author SHA1 Message Date
Oskar 8333545660 Swift 4.1, carthage support 2018-07-10 17:19:15 +02:00
Oskar Groth 4be5d991d6 Merge pull request #2 from briankeane/fixInitialValues
add awakeFromNib to make sure ibdesignable elements are refreshed wit…
2018-02-26 16:55:12 +01:00
OskarGroth d0e5cfa4d6 Swift 4 2017-11-04 18:14:18 +01:00
briankeane f9159b1121 add awakeFromNib to make sure ibdesignable elements are refreshed with newly set values 2017-10-19 10:02:30 -05:00
OskarGroth 2641ba660d 10.13 fix 2017-06-15 10:38:04 +02:00
OskarGroth 2cebd10d55 Remove print, deployment 2017-05-29 11:07:22 +02:00
Oskar Groth 5de3413003 Update README.md 2017-05-21 16:34:31 +02:00
Oskar Groth 1b189433da Update README.md 2017-05-21 16:34:21 +02:00
Oskar Groth 64efed6619 Credit 2017-05-21 16:33:08 +02:00
OskarGroth 127d4cd6ab New demo/screenshot 2017-05-21 16:28:28 +02:00
OskarGroth b575f97bde Screenshot 2017-05-21 14:09:14 +02:00
OskarGroth 315867ebb2 Fix for 10.9 2017-05-21 13:58:10 +02:00
Oskar Groth cf4468cb36 Create README.md 2017-05-21 13:51:41 +02:00
Oskar Groth 9536f15b16 Disabled styling 2017-04-18 10:49:35 +02:00
Oskar Groth 7538b3f2f4 Disabled opacity lower 2017-04-18 10:45:24 +02:00
Oskar Groth 19026b39f2 Pod bump 2017-04-11 11:20:54 +02:00
Oskar Groth 1e0dabd686 isEnabled animation 2017-04-11 11:20:06 +02:00
Oskar Groth 32f6a6d397 Pod 2017-04-10 09:57:24 +02:00
Oskar Groth 0523e2578c SetOn 2017-04-10 09:56:21 +02:00
Oskar Groth 2e199eed4d Initial coloring, IBVar reloads 2017-04-08 14:22:18 +02:00
Oskar Groth 4b50636ab8 Podspec 2017-04-08 14:17:09 +02:00
Oskar Groth 4cef47a199 Action correct status fix 2017-04-08 14:13:16 +02:00
Oskar Groth 3707a7070d Prints, states 2017-02-26 22:00:28 +11:00
Oskar Groth f9659ddd83 Podfile 2017-02-26 20:29:18 +11:00
Oskar Groth 4639c44b03 Ratio 2017-02-26 20:10:20 +11:00
Oskar Groth 5d29531a64 Image 2017-02-26 19:54:03 +11:00
20 changed files with 499 additions and 166 deletions
+9
View File
@@ -0,0 +1,9 @@
The MIT License (MIT)
Copyright (c) 2016 Oskar Groth
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+24
View File
@@ -0,0 +1,24 @@
Pod::Spec.new do |s|
s.name = 'OGSwitch'
s.version = '1.0'
s.summary = 'Switch Control for macOS'
s.homepage = 'https://github.com/OskarGroth/OGSwitch'
s.license = {
:type => 'MIT',
:file => 'LICENSE'
}
s.author = {
'Oskar Groth' => 'oskar@cindori.org'
}
s.source = {
:git => 'https://github.com/OskarGroth/OGSwitch.git',
:tag => s.version.to_s
}
s.platform = :osx, '10.9'
s.source_files = 'OGSwitch/OGSwitch.{swift}'
s.requires_arc = true
s.screenshot = "https://raw.githubusercontent.com/OskarGroth/OGSwitch/master/screenshot.jpg"
s.social_media_url = "https://twitter.com/cindoriapps"
end
+197 -110
View File
@@ -7,35 +7,61 @@
objects = {
/* Begin PBXBuildFile section */
750F2E3E1E5D2CD000C20E79 /* OGSwitch.h in Headers */ = {isa = PBXBuildFile; fileRef = 750F2E3C1E5D2CD000C20E79 /* OGSwitch.h */; settings = {ATTRIBUTES = (Public, ); }; };
750F2E451E5D2CE100C20E79 /* OGSwitch.swift in Sources */ = {isa = PBXBuildFile; fileRef = 750F2E441E5D2CE100C20E79 /* OGSwitch.swift */; };
750F2E4D1E5D2D7100C20E79 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 750F2E4C1E5D2D7100C20E79 /* AppDelegate.swift */; };
750F2E4F1E5D2D7100C20E79 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 750F2E4E1E5D2D7100C20E79 /* Assets.xcassets */; };
750F2E521E5D2D7200C20E79 /* MainMenu.xib in Resources */ = {isa = PBXBuildFile; fileRef = 750F2E501E5D2D7200C20E79 /* MainMenu.xib */; };
750F2E581E5D2F6300C20E79 /* OGSwitch.swift in Sources */ = {isa = PBXBuildFile; fileRef = 750F2E441E5D2CE100C20E79 /* OGSwitch.swift */; };
7553A35220F5045900EEA571 /* OGSwitch.h in Headers */ = {isa = PBXBuildFile; fileRef = 7553A35020F5045900EEA571 /* OGSwitch.h */; settings = {ATTRIBUTES = (Public, ); }; };
7553A35520F5045900EEA571 /* OGSwitch.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 7553A34E20F5045900EEA571 /* OGSwitch.framework */; };
7553A35620F5045900EEA571 /* OGSwitch.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 7553A34E20F5045900EEA571 /* OGSwitch.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
7553A35B20F5045F00EEA571 /* OGSwitch.swift in Sources */ = {isa = PBXBuildFile; fileRef = 750F2E441E5D2CE100C20E79 /* OGSwitch.swift */; };
/* End PBXBuildFile section */
/* Begin PBXContainerItemProxy section */
7553A35320F5045900EEA571 /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = 750F2E301E5D2CD000C20E79 /* Project object */;
proxyType = 1;
remoteGlobalIDString = 7553A34D20F5045900EEA571;
remoteInfo = OGSwitch;
};
/* End PBXContainerItemProxy section */
/* Begin PBXCopyFilesBuildPhase section */
7553A35A20F5045900EEA571 /* Embed Frameworks */ = {
isa = PBXCopyFilesBuildPhase;
buildActionMask = 2147483647;
dstPath = "";
dstSubfolderSpec = 10;
files = (
7553A35620F5045900EEA571 /* OGSwitch.framework in Embed Frameworks */,
);
name = "Embed Frameworks";
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXCopyFilesBuildPhase section */
/* Begin PBXFileReference section */
750F2E391E5D2CD000C20E79 /* OGSwitch.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = OGSwitch.framework; sourceTree = BUILT_PRODUCTS_DIR; };
750F2E3C1E5D2CD000C20E79 /* OGSwitch.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = OGSwitch.h; sourceTree = "<group>"; };
750F2E3D1E5D2CD000C20E79 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
750F2E441E5D2CE100C20E79 /* OGSwitch.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = OGSwitch.swift; sourceTree = "<group>"; };
750F2E4A1E5D2D7100C20E79 /* OGSwitchDemo.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = OGSwitchDemo.app; sourceTree = BUILT_PRODUCTS_DIR; };
750F2E4C1E5D2D7100C20E79 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
750F2E4E1E5D2D7100C20E79 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
750F2E511E5D2D7200C20E79 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Base.lproj/MainMenu.xib; sourceTree = "<group>"; };
750F2E531E5D2D7200C20E79 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
7553A34E20F5045900EEA571 /* OGSwitch.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = OGSwitch.framework; sourceTree = BUILT_PRODUCTS_DIR; };
7553A35020F5045900EEA571 /* OGSwitch.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = OGSwitch.h; sourceTree = "<group>"; };
7553A35120F5045900EEA571 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
750F2E351E5D2CD000C20E79 /* Frameworks */ = {
750F2E471E5D2D7100C20E79 /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
7553A35520F5045900EEA571 /* OGSwitch.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
750F2E471E5D2D7100C20E79 /* Frameworks */ = {
7553A34B20F5045900EEA571 /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
@@ -50,6 +76,7 @@
children = (
750F2E3B1E5D2CD000C20E79 /* OGSwitch */,
750F2E4B1E5D2D7100C20E79 /* OGSwitchDemo */,
7553A34F20F5045900EEA571 /* OGSwitch */,
750F2E3A1E5D2CD000C20E79 /* Products */,
);
sourceTree = "<group>";
@@ -57,8 +84,8 @@
750F2E3A1E5D2CD000C20E79 /* Products */ = {
isa = PBXGroup;
children = (
750F2E391E5D2CD000C20E79 /* OGSwitch.framework */,
750F2E4A1E5D2D7100C20E79 /* OGSwitchDemo.app */,
7553A34E20F5045900EEA571 /* OGSwitch.framework */,
);
name = Products;
sourceTree = "<group>";
@@ -66,9 +93,7 @@
750F2E3B1E5D2CD000C20E79 /* OGSwitch */ = {
isa = PBXGroup;
children = (
750F2E3C1E5D2CD000C20E79 /* OGSwitch.h */,
750F2E441E5D2CE100C20E79 /* OGSwitch.swift */,
750F2E3D1E5D2CD000C20E79 /* Info.plist */,
);
path = OGSwitch;
sourceTree = "<group>";
@@ -84,38 +109,29 @@
path = OGSwitchDemo;
sourceTree = "<group>";
};
7553A34F20F5045900EEA571 /* OGSwitch */ = {
isa = PBXGroup;
children = (
7553A35020F5045900EEA571 /* OGSwitch.h */,
7553A35120F5045900EEA571 /* Info.plist */,
);
path = OGSwitch;
sourceTree = "<group>";
};
/* End PBXGroup section */
/* Begin PBXHeadersBuildPhase section */
750F2E361E5D2CD000C20E79 /* Headers */ = {
7553A34920F5045900EEA571 /* Headers */ = {
isa = PBXHeadersBuildPhase;
buildActionMask = 2147483647;
files = (
750F2E3E1E5D2CD000C20E79 /* OGSwitch.h in Headers */,
7553A35220F5045900EEA571 /* OGSwitch.h in Headers */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXHeadersBuildPhase section */
/* Begin PBXNativeTarget section */
750F2E381E5D2CD000C20E79 /* OGSwitch */ = {
isa = PBXNativeTarget;
buildConfigurationList = 750F2E411E5D2CD000C20E79 /* Build configuration list for PBXNativeTarget "OGSwitch" */;
buildPhases = (
750F2E341E5D2CD000C20E79 /* Sources */,
750F2E351E5D2CD000C20E79 /* Frameworks */,
750F2E361E5D2CD000C20E79 /* Headers */,
750F2E371E5D2CD000C20E79 /* Resources */,
);
buildRules = (
);
dependencies = (
);
name = OGSwitch;
productName = OGSwitch;
productReference = 750F2E391E5D2CD000C20E79 /* OGSwitch.framework */;
productType = "com.apple.product-type.framework";
};
750F2E491E5D2D7100C20E79 /* OGSwitchDemo */ = {
isa = PBXNativeTarget;
buildConfigurationList = 750F2E541E5D2D7200C20E79 /* Build configuration list for PBXNativeTarget "OGSwitchDemo" */;
@@ -123,16 +139,36 @@
750F2E461E5D2D7100C20E79 /* Sources */,
750F2E471E5D2D7100C20E79 /* Frameworks */,
750F2E481E5D2D7100C20E79 /* Resources */,
7553A35A20F5045900EEA571 /* Embed Frameworks */,
);
buildRules = (
);
dependencies = (
7553A35420F5045900EEA571 /* PBXTargetDependency */,
);
name = OGSwitchDemo;
productName = OGSwitchDemo;
productReference = 750F2E4A1E5D2D7100C20E79 /* OGSwitchDemo.app */;
productType = "com.apple.product-type.application";
};
7553A34D20F5045900EEA571 /* OGSwitch */ = {
isa = PBXNativeTarget;
buildConfigurationList = 7553A35920F5045900EEA571 /* Build configuration list for PBXNativeTarget "OGSwitch" */;
buildPhases = (
7553A34920F5045900EEA571 /* Headers */,
7553A34A20F5045900EEA571 /* Sources */,
7553A34B20F5045900EEA571 /* Frameworks */,
7553A34C20F5045900EEA571 /* Resources */,
);
buildRules = (
);
dependencies = (
);
name = OGSwitch;
productName = OGSwitch;
productReference = 7553A34E20F5045900EEA571 /* OGSwitch.framework */;
productType = "com.apple.product-type.framework";
};
/* End PBXNativeTarget section */
/* Begin PBXProject section */
@@ -140,18 +176,18 @@
isa = PBXProject;
attributes = {
LastSwiftUpdateCheck = 0820;
LastUpgradeCheck = 0820;
LastUpgradeCheck = 1000;
ORGANIZATIONNAME = "Oskar Groth";
TargetAttributes = {
750F2E381E5D2CD000C20E79 = {
CreatedOnToolsVersion = 8.2.1;
DevelopmentTeam = ZQK6SX26CE;
LastSwiftMigration = 0820;
ProvisioningStyle = Automatic;
};
750F2E491E5D2D7100C20E79 = {
CreatedOnToolsVersion = 8.2.1;
DevelopmentTeam = ZQK6SX26CE;
LastSwiftMigration = 0910;
ProvisioningStyle = Automatic;
};
7553A34D20F5045900EEA571 = {
CreatedOnToolsVersion = 10.0;
DevelopmentTeam = ZQK6SX26CE;
ProvisioningStyle = Automatic;
};
};
@@ -169,20 +205,13 @@
projectDirPath = "";
projectRoot = "";
targets = (
750F2E381E5D2CD000C20E79 /* OGSwitch */,
750F2E491E5D2D7100C20E79 /* OGSwitchDemo */,
7553A34D20F5045900EEA571 /* OGSwitch */,
);
};
/* End PBXProject section */
/* Begin PBXResourcesBuildPhase section */
750F2E371E5D2CD000C20E79 /* Resources */ = {
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
);
runOnlyForDeploymentPostprocessing = 0;
};
750F2E481E5D2D7100C20E79 /* Resources */ = {
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
@@ -192,28 +221,42 @@
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXResourcesBuildPhase section */
/* Begin PBXSourcesBuildPhase section */
750F2E341E5D2CD000C20E79 /* Sources */ = {
isa = PBXSourcesBuildPhase;
7553A34C20F5045900EEA571 /* Resources */ = {
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
750F2E451E5D2CE100C20E79 /* OGSwitch.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXResourcesBuildPhase section */
/* Begin PBXSourcesBuildPhase section */
750F2E461E5D2D7100C20E79 /* Sources */ = {
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
750F2E4D1E5D2D7100C20E79 /* AppDelegate.swift in Sources */,
750F2E581E5D2F6300C20E79 /* OGSwitch.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
7553A34A20F5045900EEA571 /* Sources */ = {
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
7553A35B20F5045F00EEA571 /* OGSwitch.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXSourcesBuildPhase section */
/* Begin PBXTargetDependency section */
7553A35420F5045900EEA571 /* PBXTargetDependency */ = {
isa = PBXTargetDependency;
target = 7553A34D20F5045900EEA571 /* OGSwitch */;
targetProxy = 7553A35320F5045900EEA571 /* PBXContainerItemProxy */;
};
/* End PBXTargetDependency section */
/* Begin PBXVariantGroup section */
750F2E501E5D2D7200C20E79 /* MainMenu.xib */ = {
isa = PBXVariantGroup;
@@ -235,15 +278,23 @@
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
@@ -267,12 +318,14 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
MACOSX_DEPLOYMENT_TARGET = 10.12;
MACOSX_DEPLOYMENT_TARGET = 10.9;
MTL_ENABLE_DEBUG_INFO = YES;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = macosx;
SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
SWIFT_VERSION = 4.0;
VERSIONING_SYSTEM = "apple-generic";
VERSION_INFO_PREFIX = "";
};
@@ -287,15 +340,23 @@
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
@@ -313,85 +374,109 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
MACOSX_DEPLOYMENT_TARGET = 10.12;
MACOSX_DEPLOYMENT_TARGET = 10.9;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = macosx;
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
SWIFT_VERSION = 4.0;
VERSIONING_SYSTEM = "apple-generic";
VERSION_INFO_PREFIX = "";
};
name = Release;
};
750F2E421E5D2CD000C20E79 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_IDENTITY = "";
COMBINE_HIDPI_IMAGES = YES;
DEFINES_MODULE = YES;
DEVELOPMENT_TEAM = ZQK6SX26CE;
DYLIB_COMPATIBILITY_VERSION = 1;
DYLIB_CURRENT_VERSION = 1;
DYLIB_INSTALL_NAME_BASE = "@rpath";
FRAMEWORK_VERSION = A;
INFOPLIST_FILE = OGSwitch/Info.plist;
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = org.cindori.OGSwitch;
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 3.0;
};
name = Debug;
};
750F2E431E5D2CD000C20E79 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_IDENTITY = "";
COMBINE_HIDPI_IMAGES = YES;
DEFINES_MODULE = YES;
DEVELOPMENT_TEAM = ZQK6SX26CE;
DYLIB_COMPATIBILITY_VERSION = 1;
DYLIB_CURRENT_VERSION = 1;
DYLIB_INSTALL_NAME_BASE = "@rpath";
FRAMEWORK_VERSION = A;
INFOPLIST_FILE = OGSwitch/Info.plist;
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = org.cindori.OGSwitch;
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
SWIFT_VERSION = 3.0;
};
name = Release;
};
750F2E551E5D2D7200C20E79 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
COMBINE_HIDPI_IMAGES = YES;
DEVELOPMENT_TEAM = ZQK6SX26CE;
INFOPLIST_FILE = OGSwitchDemo/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks";
MACOSX_DEPLOYMENT_TARGET = 10.10;
PRODUCT_BUNDLE_IDENTIFIER = org.cindori.OGSwitchDemo;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 3.0;
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
SWIFT_VERSION = 4.0;
};
name = Debug;
};
750F2E561E5D2D7200C20E79 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
COMBINE_HIDPI_IMAGES = YES;
DEVELOPMENT_TEAM = ZQK6SX26CE;
INFOPLIST_FILE = OGSwitchDemo/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks";
MACOSX_DEPLOYMENT_TARGET = 10.10;
PRODUCT_BUNDLE_IDENTIFIER = org.cindori.OGSwitchDemo;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 3.0;
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
SWIFT_VERSION = 4.0;
};
name = Release;
};
7553A35720F5045900EEA571 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++14";
CLANG_ENABLE_OBJC_WEAK = YES;
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
CODE_SIGN_IDENTITY = "-";
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
DEFINES_MODULE = YES;
DEVELOPMENT_TEAM = ZQK6SX26CE;
DYLIB_COMPATIBILITY_VERSION = 1;
DYLIB_CURRENT_VERSION = 1;
DYLIB_INSTALL_NAME_BASE = "@rpath";
FRAMEWORK_VERSION = A;
GCC_C_LANGUAGE_STANDARD = gnu11;
INFOPLIST_FILE = OGSwitch/Info.plist;
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/Frameworks";
MACOSX_DEPLOYMENT_TARGET = 10.10;
MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
PRODUCT_BUNDLE_IDENTIFIER = org.cindori.OGSwitch;
PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)";
SKIP_INSTALL = YES;
SWIFT_VERSION = 4.2;
};
name = Debug;
};
7553A35820F5045900EEA571 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++14";
CLANG_ENABLE_OBJC_WEAK = YES;
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
CODE_SIGN_IDENTITY = "-";
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
DEFINES_MODULE = YES;
DEVELOPMENT_TEAM = ZQK6SX26CE;
DYLIB_COMPATIBILITY_VERSION = 1;
DYLIB_CURRENT_VERSION = 1;
DYLIB_INSTALL_NAME_BASE = "@rpath";
FRAMEWORK_VERSION = A;
GCC_C_LANGUAGE_STANDARD = gnu11;
INFOPLIST_FILE = OGSwitch/Info.plist;
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/Frameworks";
MACOSX_DEPLOYMENT_TARGET = 10.10;
PRODUCT_BUNDLE_IDENTIFIER = org.cindori.OGSwitch;
PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)";
SKIP_INSTALL = YES;
SWIFT_VERSION = 4.2;
};
name = Release;
};
@@ -407,14 +492,6 @@
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
750F2E411E5D2CD000C20E79 /* Build configuration list for PBXNativeTarget "OGSwitch" */ = {
isa = XCConfigurationList;
buildConfigurations = (
750F2E421E5D2CD000C20E79 /* Debug */,
750F2E431E5D2CD000C20E79 /* Release */,
);
defaultConfigurationIsVisible = 0;
};
750F2E541E5D2D7200C20E79 /* Build configuration list for PBXNativeTarget "OGSwitchDemo" */ = {
isa = XCConfigurationList;
buildConfigurations = (
@@ -422,6 +499,16 @@
750F2E561E5D2D7200C20E79 /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
7553A35920F5045900EEA571 /* Build configuration list for PBXNativeTarget "OGSwitch" */ = {
isa = XCConfigurationList;
buildConfigurations = (
7553A35720F5045900EEA571 /* Debug */,
7553A35820F5045900EEA571 /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
/* End XCConfigurationList section */
};
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>IDEDidComputeMac32BitWarning</key>
<true/>
</dict>
</plist>
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0820"
LastUpgradeVersion = "1000"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
@@ -14,7 +14,7 @@
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "750F2E381E5D2CD000C20E79"
BlueprintIdentifier = "7553A34D20F5045900EEA571"
BuildableName = "OGSwitch.framework"
BlueprintName = "OGSwitch"
ReferencedContainer = "container:OGSwitch.xcodeproj">
@@ -45,7 +45,7 @@
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "750F2E381E5D2CD000C20E79"
BlueprintIdentifier = "7553A34D20F5045900EEA571"
BuildableName = "OGSwitch.framework"
BlueprintName = "OGSwitch"
ReferencedContainer = "container:OGSwitch.xcodeproj">
@@ -63,7 +63,7 @@
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "750F2E381E5D2CD000C20E79"
BlueprintIdentifier = "7553A34D20F5045900EEA571"
BuildableName = "OGSwitch.framework"
BlueprintName = "OGSwitch"
ReferencedContainer = "container:OGSwitch.xcodeproj">
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<Bucket
type = "1"
version = "2.0">
</Bucket>
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0820"
LastUpgradeVersion = "1000"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
@@ -7,12 +7,12 @@
<key>OGSwitch.xcscheme_^#shared#^_</key>
<dict>
<key>orderHint</key>
<integer>0</integer>
<integer>1</integer>
</dict>
<key>OGSwitchDemo.xcscheme</key>
<dict>
<key>orderHint</key>
<integer>1</integer>
<integer>0</integer>
</dict>
</dict>
<key>SuppressBuildableAutocreation</key>
+2 -4
View File
@@ -3,7 +3,7 @@
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<string>$(DEVELOPMENT_LANGUAGE)</string>
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>
@@ -19,8 +19,6 @@
<key>CFBundleVersion</key>
<string>$(CURRENT_PROJECT_VERSION)</string>
<key>NSHumanReadableCopyright</key>
<string>Copyright © 2017 Oskar Groth. All rights reserved.</string>
<key>NSPrincipalClass</key>
<string></string>
<string>Copyright © 2018 Oskar Groth. All rights reserved.</string>
</dict>
</plist>
+2 -2
View File
@@ -2,8 +2,8 @@
// OGSwitch.h
// OGSwitch
//
// Created by Oskar Groth on 2017-02-22.
// Copyright © 2017 Oskar Groth. All rights reserved.
// Created by Oskar Groth on 2018-07-10.
// Copyright © 2018 Oskar Groth. All rights reserved.
//
#import <Cocoa/Cocoa.h>
+122 -37
View File
@@ -9,21 +9,57 @@
import Cocoa
import QuartzCore
public class OGSwitch : NSControl {
//Can not be NSControl due to 10.9 issues: https://github.com/iluuu1994/ITSwitch/issues/21
@IBInspectable public var tintColor: NSColor = NSColor(calibratedRed:0.27, green: 0.86, blue: 0.36, alpha: 1.0)
@IBInspectable public var knobBackgroundColor: NSColor = NSColor(calibratedWhite:1.0, alpha: 1.0)
@IBInspectable public var disabledBorderColor: NSColor = NSColor(calibratedWhite: 0.0, alpha: 0.2)
@IBInspectable public var disabledBackgroundColor: NSColor = NSColor.clear
@IBInspectable public var inactiveBackgroundColor: NSColor = NSColor(calibratedWhite: 0.0, alpha:0.3)
public class OGSwitch : NSView {
@IBInspectable public var tintColor: NSColor = NSColor(calibratedRed:0.27, green: 0.86, blue: 0.36, alpha: 1.0) {
didSet {
reloadLayer()
}
}
@IBInspectable public var knobBackgroundColor: NSColor = NSColor(calibratedWhite:1.0, alpha: 1.0) {
didSet {
reloadLayer()
}
}
@IBInspectable public var disabledBorderColor: NSColor = NSColor(calibratedWhite: 0.0, alpha: 0.2) {
didSet {
reloadLayer()
}
}
@IBInspectable public var disabledBackgroundColor: NSColor = NSColor.clear {
didSet {
reloadLayer()
}
}
@IBInspectable public var inactiveBackgroundColor: NSColor = NSColor(calibratedWhite: 0.0, alpha:0.3) {
didSet {
reloadLayer()
}
}
@IBInspectable public var animationDuration: TimeInterval = 0.4
@IBInspectable public var inactiveIcon: NSImage? {
didSet {
reloadLayer()
}
}
@IBInspectable public var activeIcon: NSImage? {
didSet {
reloadLayer()
}
}
@IBInspectable public var ignoreRatio: Bool = false
let kBorderLineWidth:CGFloat = 1.0
let kGoldenRatio:CGFloat = 1.6180339875
let kDecreasedGoldenRatio:CGFloat = 1.38
let kEnabledOpacity:Float = 1.0
let kDisabledOpacity:Float = 0.5
public var isOn:Bool = true
var dragEvents = 0
@objc public var action: Selector?
@objc public var target: AnyObject?
public var isOn:Bool = false
public var isActive:Bool = false
public var hasDragged:Bool = false
public var isDraggingTowardsOn:Bool = false
@@ -31,6 +67,13 @@ public class OGSwitch : NSControl {
public var backgroundLayer:CALayer?
public var knobLayer: CALayer?
public var knobInsideLayer: CALayer?
public var iconLayer = CALayer()
public var lockInteraction: Bool = false
public var isEnabled: Bool = true {
didSet {
reloadLayerAnimated(animated: true)
}
}
override public var acceptsFirstResponder: Bool {
get {
@@ -40,32 +83,64 @@ public class OGSwitch : NSControl {
required public init?(coder:NSCoder) {
super.init(coder: coder)
setup()
}
override init(frame:NSRect) {
super.init(frame: frame);
setup()
}
override public func awakeFromNib() {
super.awakeFromNib()
reloadLayerSize()
reloadLayer()
setupIcon()
}
internal func setup() {
isEnabled = true
setupLayers()
}
public func setOn(isOn: Bool, animated: Bool) {
if self.isOn != isOn {
self.isOn = isOn
reloadLayerAnimated(animated: animated)
}
}
internal func setupIcon() {
guard let icon = inactiveIcon, let bounds = knobLayer?.bounds else {
return
}
let size = icon.size
iconLayer.frame = NSMakeRect((bounds.width-size.width)/2, (bounds.height-size.height)/2, size.width, size.height)
iconLayer.contents = icon
}
internal func animateImage() {
let animation = CABasicAnimation(keyPath: "contents")
animation.toValue = isOn ? activeIcon : inactiveIcon
animation.fromValue = iconLayer.contents
animation.duration = 0.5
animation.isRemovedOnCompletion = false
animation.fillMode = .forwards
iconLayer.add(animation, forKey: "contents")
iconLayer.setValue(animation.toValue, forKey: "contents")
}
internal func setupLayers() {
rootLayer = CALayer()
layer = rootLayer
wantsLayer = true
layer?.masksToBounds = false
backgroundLayer = CALayer()
backgroundLayer!.autoresizingMask = [.layerWidthSizable, .layerHeightSizable]
backgroundLayer!.bounds = rootLayer!.bounds
backgroundLayer!.anchorPoint = CGPoint(x: 0.0, y: 0.0)
backgroundLayer!.borderWidth = kBorderLineWidth
backgroundLayer?.masksToBounds = false
rootLayer!.addSublayer(backgroundLayer!)
@@ -77,12 +152,16 @@ public class OGSwitch : NSControl {
knobLayer!.shadowOffset = CGSize(width:0.0, height:-2.0)
knobLayer!.shadowRadius = 1.0
knobLayer!.shadowOpacity = 0.3
knobLayer?.masksToBounds = false
rootLayer!.addSublayer(knobLayer!)
knobInsideLayer = CALayer()
knobInsideLayer!.frame = knobLayer!.bounds
knobInsideLayer!.autoresizingMask = [.layerHeightSizable, .layerWidthSizable]
iconLayer = CALayer()
knobInsideLayer?.addSublayer(iconLayer)
knobInsideLayer!.shadowColor = NSColor.black.cgColor
knobInsideLayer!.shadowOffset = CGSize(width:0.0, height:0.0)
knobInsideLayer!.backgroundColor = NSColor.white.cgColor
@@ -97,36 +176,32 @@ public class OGSwitch : NSControl {
internal func reloadLayerSize() {
CATransaction.begin()
CATransaction.setDisableActions(true)
knobLayer!.frame = rectForKnob()
knobInsideLayer!.frame = knobLayer!.bounds
backgroundLayer!.cornerRadius = backgroundLayer!.bounds.size.height / 2.0
knobLayer!.cornerRadius = knobLayer!.bounds.size.height / 2.0
knobInsideLayer!.cornerRadius = knobLayer!.bounds.size.height / 2.0
CATransaction.commit()
}
public func reloadLayerAnimated(animated: Bool) {
guard let backgroundLayer = backgroundLayer else {
return
}
CATransaction.begin()
CATransaction.setAnimationDuration(animated ? animationDuration : 0)
if (hasDragged && isDraggingTowardsOn) || (!hasDragged && isOn) {
backgroundLayer!.borderColor = tintColor.cgColor
backgroundLayer!.backgroundColor = tintColor.cgColor
backgroundLayer.borderColor = tintColor.cgColor
backgroundLayer.backgroundColor = tintColor.cgColor
}
else {
backgroundLayer!.borderColor = disabledBorderColor.cgColor
backgroundLayer!.backgroundColor = disabledBackgroundColor.cgColor
backgroundLayer.borderColor = disabledBorderColor.cgColor
backgroundLayer.backgroundColor = disabledBackgroundColor.cgColor
}
if isEnabled {
rootLayer!.opacity = kEnabledOpacity
}
else {
rootLayer!.opacity = kDisabledOpacity
}
knobLayer?.shadowColor = isEnabled ? NSColor.black.cgColor : NSColor.clear.cgColor
rootLayer!.opacity = isEnabled ? kEnabledOpacity : kDisabledOpacity
if hasDragged {
let function = CAMediaTimingFunction(controlPoints: 0.25, 1.5, 0.5, 1)
@@ -137,6 +212,7 @@ public class OGSwitch : NSControl {
knobInsideLayer!.frame = knobLayer!.bounds
CATransaction.commit()
animateImage()
}
public func reloadLayer() {
@@ -152,12 +228,15 @@ public class OGSwitch : NSControl {
var width = 0.0
let bounds: CGRect = backgroundLayer!.bounds
if isActive {
width = Double((bounds.width - 2.0 * kBorderLineWidth) / kGoldenRatio)
}
else {
width = Double((bounds.width - 2.0 * kBorderLineWidth) / kDecreasedGoldenRatio)
if ignoreRatio {
width = Double(height)
} else {
if isActive {
width = Double((bounds.width - 2.0 * kBorderLineWidth) / kGoldenRatio)
}
else {
width = Double((bounds.width - 2.0 * kBorderLineWidth) / kDecreasedGoldenRatio)
}
}
var x:CGFloat = 0
@@ -183,7 +262,7 @@ public class OGSwitch : NSControl {
override public func mouseDown(with theEvent: NSEvent) {
if !isEnabled {
if !isEnabled || lockInteraction {
return
}
isActive = true
@@ -191,10 +270,14 @@ public class OGSwitch : NSControl {
}
override public func mouseDragged(with theEvent: NSEvent) {
if !isEnabled {
dragEvents += 1
guard dragEvents > 3 else {
return
}
dragEvents = 0
if !isEnabled || lockInteraction {
return
}
hasDragged = true
let draggingPoint = convert(theEvent.locationInWindow, from: nil)
@@ -203,7 +286,8 @@ public class OGSwitch : NSControl {
}
override public func mouseUp(with theEvent: NSEvent) {
if !isEnabled {
dragEvents = 0
if !isEnabled || lockInteraction {
return
}
@@ -217,14 +301,14 @@ public class OGSwitch : NSControl {
}
if isOn != on {
Swift.print("Now: \(on)")
isOn = on
if action != nil {
NSApp.sendAction(action!, to: target, from: self)
}
} else {
isOn = on
}
isOn = on
hasDragged = false
isDraggingTowardsOn = false
@@ -232,3 +316,4 @@ public class OGSwitch : NSControl {
}
}
+11 -1
View File
@@ -7,12 +7,13 @@
//
import Cocoa
import OGSwitch
@NSApplicationMain
class AppDelegate: NSObject, NSApplicationDelegate {
@IBOutlet weak var window: NSWindow!
@IBOutlet weak var switchButton: OGSwitch!
func applicationDidFinishLaunching(_ aNotification: Notification) {
// Insert code here to initialize your application
@@ -22,6 +23,15 @@ class AppDelegate: NSObject, NSApplicationDelegate {
// Insert code here to tear down your application
}
@IBAction func switchPress(_ sender: Any) {
NSLog("Switch is now: \(switchButton.isOn)")
// perform(#selector(timer), with: nil, afterDelay: 3)
}
@objc func timer() {
NSLog("Switch is after timer trigger now: \(switchButton.isOn)")
// switchButton.setOn(isOn: !switchButton.isOn, animated: false)
}
}
@@ -0,0 +1,6 @@
{
"info" : {
"version" : 1,
"author" : "xcode"
}
}
@@ -0,0 +1,22 @@
{
"images" : [
{
"idiom" : "universal",
"filename" : "checkmark.png",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "checkmark@2x.png",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

+34 -5
View File
@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="11762" systemVersion="16D32" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="14269.12" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
<dependencies>
<deployment identifier="macosx"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="11762"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="14269.12"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<objects>
@@ -15,6 +15,7 @@
<customObject id="-3" userLabel="Application" customClass="NSObject"/>
<customObject id="Voe-Tx-rLC" customClass="AppDelegate" customModule="OGSwitchDemo" customModuleProvider="target">
<connections>
<outlet property="switchButton" destination="M7z-uc-a7v" id="s1F-OI-IzO"/>
<outlet property="window" destination="QvC-M9-y7g" id="gIp-Ho-8D9"/>
</connections>
</customObject>
@@ -684,17 +685,45 @@
<windowStyleMask key="styleMask" titled="YES" closable="YES" miniaturizable="YES" resizable="YES"/>
<windowPositionMask key="initialPositionMask" leftStrut="YES" rightStrut="YES" topStrut="YES" bottomStrut="YES"/>
<rect key="contentRect" x="335" y="390" width="480" height="360"/>
<rect key="screenRect" x="0.0" y="0.0" width="1680" height="1028"/>
<rect key="screenRect" x="0.0" y="0.0" width="1680" height="1027"/>
<view key="contentView" wantsLayer="YES" id="EiT-Mj-1SZ">
<rect key="frame" x="0.0" y="0.0" width="480" height="360"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<customView fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="ME7-To-eFM" customClass="OGSwitch" customModule="OGSwitchDemo" customModuleProvider="target">
<rect key="frame" x="159" y="144" width="163" height="96"/>
<customView fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="M7z-uc-a7v" customClass="OGSwitch" customModule="OGSwitch">
<rect key="frame" x="159" y="201" width="163" height="96"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<userDefinedRuntimeAttributes>
<userDefinedRuntimeAttribute type="boolean" keyPath="ignoreRatio" value="YES"/>
<userDefinedRuntimeAttribute type="color" keyPath="disabledBackgroundColor">
<color key="value" red="1" green="0.40000000600000002" blue="0.40000000600000002" alpha="1" colorSpace="calibratedRGB"/>
</userDefinedRuntimeAttribute>
</userDefinedRuntimeAttributes>
<connections>
<action selector="switchPress:" target="Voe-Tx-rLC" id="Mqi-G6-fmv"/>
</connections>
</customView>
<customView fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="Brb-kf-Oxi" customClass="OGSwitch" customModule="OGSwitch">
<rect key="frame" x="159" y="63" width="163" height="96"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<userDefinedRuntimeAttributes>
<userDefinedRuntimeAttribute type="image" keyPath="activeIcon" value="checkmark"/>
<userDefinedRuntimeAttribute type="boolean" keyPath="ignoreRatio" value="YES"/>
<userDefinedRuntimeAttribute type="color" keyPath="disabledBackgroundColor">
<color key="value" red="1" green="0.40000000600000002" blue="0.40000000600000002" alpha="1" colorSpace="calibratedRGB"/>
</userDefinedRuntimeAttribute>
<userDefinedRuntimeAttribute type="image" keyPath="inactiveIcon" value="checkmark"/>
</userDefinedRuntimeAttributes>
<connections>
<action selector="switchPress:" target="Voe-Tx-rLC" id="tTg-hX-q3I"/>
</connections>
</customView>
</subviews>
</view>
<point key="canvasLocation" x="86" y="-105"/>
</window>
</objects>
<resources>
<image name="checkmark" width="35" height="34"/>
</resources>
</document>
+50
View File
@@ -0,0 +1,50 @@
OGSwitch
==================
Layer based Switch Control for macOS, with Interface Builder styling options. Written in Swift.
Supports animation, custom aspect ratios, and knob images.
This is a `NSView` subclass that lets you create beautiful iOS-inspired switches easily.
![OGSwitch for macOS](https://s3.amazonaws.com/cindori/images/ogswitch.png "OGSwitch for macOS")
## Installation (CocoaPods)
Configure your Podfile to use `OGSwitch`:
```pod 'OGSwitch'```
## Usage
Create a custom `NSView` in Interface Builder and set it's class to `OGSwitch`.
You can now style your switch from the inspector:
![OGSwitch for macOS](https://s3.amazonaws.com/cindori/images/inspector-ogswitch.png "OGSwitch for macOS")
The same values can be accessed from your code.
## Credits
Inspired by ITSwitch by Ilija Tovilo.
## License
The MIT License (MIT)
Copyright (c) 2017 Oskar Groth
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 105 KiB