Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions KLSwitch/KLSwitch.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -191,15 +191,16 @@
name = KLSwitchTests;
productName = KLSwitchTests;
productReference = 7710F502176DE33900771BA7 /* KLSwitchTests.octest */;
productType = "com.apple.product-type.bundle";
productType = "com.apple.product-type.bundle.ocunit-test";
};
/* End PBXNativeTarget section */

/* Begin PBXProject section */
7710F4E9176DE33900771BA7 /* Project object */ = {
isa = PBXProject;
attributes = {
LastUpgradeCheck = 0460;
LastTestingUpgradeCheck = 0730;
LastUpgradeCheck = 0730;
ORGANIZATIONNAME = "Kieran Lafferty";
};
buildConfigurationList = 7710F4EC176DE33900771BA7 /* Build configuration list for PBXProject "KLSwitch" */;
Expand Down Expand Up @@ -300,6 +301,7 @@
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
COPY_PHASE_STRIP = NO;
ENABLE_TESTABILITY = YES;
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_DYNAMIC_NO_PIC = NO;
GCC_OPTIMIZATION_LEVEL = 0;
Expand Down Expand Up @@ -374,6 +376,7 @@
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = "KLSwitch/KLSwitch-Prefix.pch";
INFOPLIST_FILE = "KLSwitchTests/KLSwitchTests-Info.plist";
PRODUCT_BUNDLE_IDENTIFIER = "KL.${PRODUCT_NAME:rfc1034identifier}";
PRODUCT_NAME = "$(TARGET_NAME)";
WRAPPER_EXTENSION = octest;
};
Expand All @@ -389,6 +392,7 @@
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = "KLSwitch/KLSwitch-Prefix.pch";
INFOPLIST_FILE = "KLSwitchTests/KLSwitchTests-Info.plist";
PRODUCT_BUNDLE_IDENTIFIER = "KL.${PRODUCT_NAME:rfc1034identifier}";
PRODUCT_NAME = "$(TARGET_NAME)";
WRAPPER_EXTENSION = octest;
};
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0730"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "7710F4F0176DE33900771BA7"
BuildableName = "libKLSwitch.a"
BlueprintName = "KLSwitch"
ReferencedContainer = "container:KLSwitch.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
</Testables>
<AdditionalOptions>
</AdditionalOptions>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES">
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "7710F4F0176DE33900771BA7"
BuildableName = "libKLSwitch.a"
BlueprintName = "KLSwitch"
ReferencedContainer = "container:KLSwitch.xcodeproj">
</BuildableReference>
</MacroExpansion>
<AdditionalOptions>
</AdditionalOptions>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES">
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "7710F4F0176DE33900771BA7"
BuildableName = "libKLSwitch.a"
BlueprintName = "KLSwitch"
ReferencedContainer = "container:KLSwitch.xcodeproj">
</BuildableReference>
</MacroExpansion>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0730"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "7710F501176DE33900771BA7"
BuildableName = "KLSwitchTests.octest"
BlueprintName = "KLSwitchTests"
ReferencedContainer = "container:KLSwitch.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
</Testables>
<AdditionalOptions>
</AdditionalOptions>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES">
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "7710F501176DE33900771BA7"
BuildableName = "KLSwitchTests.octest"
BlueprintName = "KLSwitchTests"
ReferencedContainer = "container:KLSwitch.xcodeproj">
</BuildableReference>
</MacroExpansion>
<AdditionalOptions>
</AdditionalOptions>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES">
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "7710F501176DE33900771BA7"
BuildableName = "KLSwitchTests.octest"
BlueprintName = "KLSwitchTests"
ReferencedContainer = "container:KLSwitch.xcodeproj">
</BuildableReference>
</MacroExpansion>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?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>SchemeUserState</key>
<dict>
<key>KLSwitch.xcscheme</key>
<dict>
<key>orderHint</key>
<integer>2</integer>
</dict>
<key>KLSwitchTests.xcscheme</key>
<dict>
<key>orderHint</key>
<integer>3</integer>
</dict>
</dict>
<key>SuppressBuildableAutocreation</key>
<dict>
<key>7710F4F0176DE33900771BA7</key>
<dict>
<key>primary</key>
<true/>
</dict>
<key>7710F501176DE33900771BA7</key>
<dict>
<key>primary</key>
<true/>
</dict>
</dict>
</dict>
</plist>
4 changes: 4 additions & 0 deletions KLSwitch/KLSwitch/KLSwitch.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,5 +50,9 @@ typedef void(^changeHandler)(BOOL isOn);
- (void)setOn:(BOOL)on animated:(BOOL)animated;
- (void)setLocked:(BOOL)locked;

#pragma mark: setImage
- (void)setTurnOnImage:(UIImage *)turnOnImage;
- (void)setTurnOffImage:(UIImage *)turnOffImage;

@end

37 changes: 37 additions & 0 deletions KLSwitch/KLSwitch/KLSwitch.m
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,12 @@ -(void) growContrastView;
-(void) shrinkContrastView;
-(void) setOn:(BOOL) on
animated:(BOOL) animated;


#pragma mark -- setImage
- (void)addTurnOnImage:(UIImage *)image;
- (void)addTurnOffImage:(UIImage *)image;

@end


Expand Down Expand Up @@ -402,6 +408,15 @@ -(void) setThumbOn:(BOOL) on
}
[self.thumb setFrame: thumbFrame];
}

#pragma mark: setImage
- (void)setTurnOnImage:(UIImage *)turnOnImage {
[self.track addTurnOnImage:turnOnImage];
}

- (void)setTurnOffImage:(UIImage *)turnOffImage {
[self.track addTurnOffImage:turnOffImage];
}
@end


Expand Down Expand Up @@ -533,4 +548,26 @@ -(void) shrinkContrastView {
[self.contrastView setTransform: CGAffineTransformMakeScale(kSwitchTrackContrastViewShrinkFactor, kSwitchTrackContrastViewShrinkFactor)];
}

#pragma mark -- setImage
- (void)addTurnOnImage:(UIImage *)image {
NSInteger turnOnImageViewTag = 12;
UIImageView *imageView = [self.onView viewWithTag:turnOnImageViewTag];
if (imageView == nil) {
imageView = [[UIImageView alloc] initWithFrame:self.bounds];
imageView.tag = turnOnImageViewTag;
}
imageView.image = image;
[self.onView addSubview:imageView];
}
- (void)addTurnOffImage:(UIImage *)image {
NSInteger turnOffImageViewTag = 12;
UIImageView *imageView = [self.contrastView viewWithTag:turnOffImageViewTag];
if (imageView == nil) {
imageView = [[UIImageView alloc] initWithFrame:self.bounds];
imageView.tag = turnOffImageViewTag;
}
imageView.image = image;
[self.contrastView addSubview:imageView];
}

@end
2 changes: 1 addition & 1 deletion KLSwitch/KLSwitchTests/KLSwitchTests-Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<key>CFBundleExecutable</key>
<string>${EXECUTABLE_NAME}</string>
<key>CFBundleIdentifier</key>
<string>KL.${PRODUCT_NAME:rfc1034identifier}</string>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundlePackageType</key>
Expand Down
Loading