24 Commits

Author SHA1 Message Date
Cookiezby b3dbe062a1 update readme 2020-05-10 14:48:05 +09:00
zhu.bingyi bdff93eb94 Merge pull request #17 from Cookiezby/0.1.7
0.1.7
2020-05-10 14:44:58 +09:00
Cookiezby 2b6b37e4ec update ci config 2020-05-10 14:37:52 +09:00
Cookiezby 43b80fa5ad update readme 2020-05-10 14:33:38 +09:00
Cookiezby 3d931ed365 fix ib render issue 2020-05-10 14:29:53 +09:00
Cookiezby e7de224188 fix constraint 2020-05-10 14:18:21 +09:00
Cookiezby 2096ce66d5 rename method 2020-05-10 13:42:54 +09:00
Cookiezby 668f49d912 fix switch tapped 2020-05-10 13:42:38 +09:00
Cookiezby a19dedfec3 remove warning 2020-05-10 13:37:07 +09:00
Cookiezby 3a69c18500 update ci config 2019-07-23 00:22:24 +09:00
Cookiezby 0dcaeea998 improve build target 2019-07-23 00:05:40 +09:00
Cookiezby 6ec5a5d8ef uddate ci config 2019-07-22 23:55:43 +09:00
Cookiezby 8bcb52e2f4 update ci config 2019-07-22 23:46:18 +09:00
Cookiezby 6588d8458a add isEnable 2019-07-22 23:42:03 +09:00
Cookiezby 6cd2654b2a upgrade swift ver 5.0 2019-07-22 23:02:12 +09:00
zhu.bingyi 4ddb00edcb Merge pull request #11 from Cookiezby/0.1.6
0.1.6
2019-02-10 13:13:00 +09:00
Cookiezby 67adf23091 edit .travis.yml 2019-02-10 13:03:53 +09:00
Cookiezby 8ebf9518c9 fix readme, bump pod version 2019-02-10 12:57:15 +09:00
Cookiezby 7852d6a9ae fix delegate parameter 2019-02-10 12:54:42 +09:00
Cookiezby 03930ec1c4 fix travis.yml 2018-10-21 16:31:05 +09:00
Cookiezby 8e47dd330f upate travis.yml 2018-10-21 16:27:19 +09:00
Cookiezby c9e63d886d adapt to swift 4.2 2018-10-21 16:17:49 +09:00
zhu.bingyi c2467ffec4 Merge pull request #7 from dingtianran/master
Updated README to reflect v0.1.4 changes
2018-07-31 20:53:53 +09:00
Tianran Ding bfa472841a Updated README to reflect v0.1.4 changes 2018-07-31 23:47:00 +12:00
22 changed files with 672 additions and 628 deletions
+7 -7
View File
@@ -1,14 +1,14 @@
# * http://www.objc.io/issue-6/travis-ci.html
# * https://github.com/supermarin/xcpretty#usage
osx_image: xcode9.2
osx_image: xcode11.4
language: swift
# cache: cocoapods
# podfile: Example/Podfile
# before_install:
# - gem install cocoapods # Since Travis is not always on latest version
# - pod install --project-directory=Example
cache: cocoapods
podfile: Example/Podfile
before_install:
- gem install cocoapods # Since Travis is not always on latest version
# - pod install
script:
- set -o pipefail && xcodebuild test -enableCodeCoverage YES -workspace Example/LabelSwitch.xcworkspace -scheme LabelSwitch-Example -sdk iphonesimulator -destination 'platform=iOS Simulator,name=iPhone 6' ONLY_ACTIVE_ARCH=NO | xcpretty
- set -o pipefail && xcodebuild test -enableCodeCoverage YES -workspace Example/LabelSwitch.xcworkspace -scheme LabelSwitch-Example -sdk iphonesimulator -destination 'platform=iOS Simulator,name=iPhone 11' ONLY_ACTIVE_ARCH=NO | xcpretty
- pod lib lint
+16 -68
View File
@@ -177,7 +177,6 @@
607FACCD1AFB9204008FA782 /* Frameworks */,
607FACCE1AFB9204008FA782 /* Resources */,
40177D7B23047A5D3EB4F060 /* [CP] Embed Pods Frameworks */,
0C59C05A8C561B00C30729E6 /* [CP] Copy Pods Resources */,
);
buildRules = (
);
@@ -196,8 +195,6 @@
607FACE11AFB9204008FA782 /* Sources */,
607FACE21AFB9204008FA782 /* Frameworks */,
607FACE31AFB9204008FA782 /* Resources */,
18F9B0442D0C45DC90AEC65F /* [CP] Embed Pods Frameworks */,
922E547E5B168BA9ABEAE6C1 /* [CP] Copy Pods Resources */,
);
buildRules = (
);
@@ -216,23 +213,23 @@
isa = PBXProject;
attributes = {
LastSwiftUpdateCheck = 0830;
LastUpgradeCheck = 0830;
LastUpgradeCheck = 1140;
ORGANIZATIONNAME = CocoaPods;
TargetAttributes = {
607FACCF1AFB9204008FA782 = {
CreatedOnToolsVersion = 6.3.1;
LastSwiftMigration = 0900;
LastSwiftMigration = 1020;
};
607FACE41AFB9204008FA782 = {
CreatedOnToolsVersion = 6.3.1;
LastSwiftMigration = 0900;
LastSwiftMigration = 1020;
TestTargetID = 607FACCF1AFB9204008FA782;
};
};
};
buildConfigurationList = 607FACCB1AFB9204008FA782 /* Build configuration list for PBXProject "LabelSwitch" */;
compatibilityVersion = "Xcode 3.2";
developmentRegion = English;
developmentRegion = en;
hasScannedForEncodings = 0;
knownRegions = (
en,
@@ -290,36 +287,6 @@
shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n";
showEnvVarsInLog = 0;
};
0C59C05A8C561B00C30729E6 /* [CP] Copy Pods Resources */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputPaths = (
);
name = "[CP] Copy Pods Resources";
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-LabelSwitch_Example/Pods-LabelSwitch_Example-resources.sh\"\n";
showEnvVarsInLog = 0;
};
18F9B0442D0C45DC90AEC65F /* [CP] Embed Pods Frameworks */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputPaths = (
);
name = "[CP] Embed Pods Frameworks";
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-LabelSwitch_Tests/Pods-LabelSwitch_Tests-frameworks.sh\"\n";
showEnvVarsInLog = 0;
};
40177D7B23047A5D3EB4F060 /* [CP] Embed Pods Frameworks */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
@@ -356,21 +323,6 @@
shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n";
showEnvVarsInLog = 0;
};
922E547E5B168BA9ABEAE6C1 /* [CP] Copy Pods Resources */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputPaths = (
);
name = "[CP] Copy Pods Resources";
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-LabelSwitch_Tests/Pods-LabelSwitch_Tests-resources.sh\"\n";
showEnvVarsInLog = 0;
};
/* End PBXShellScriptBuildPhase section */
/* Begin PBXSourcesBuildPhase section */
@@ -433,12 +385,14 @@
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_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;
@@ -486,12 +440,14 @@
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_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;
@@ -532,8 +488,7 @@
MODULE_NAME = ExampleApp;
PRODUCT_BUNDLE_IDENTIFIER = "org.cocoapods.demo.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
SWIFT_VERSION = 4.0;
SWIFT_VERSION = 5.0;
};
name = Debug;
};
@@ -549,8 +504,7 @@
MODULE_NAME = ExampleApp;
PRODUCT_BUNDLE_IDENTIFIER = "org.cocoapods.demo.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
SWIFT_VERSION = 4.0;
SWIFT_VERSION = 5.0;
};
name = Release;
};
@@ -558,20 +512,17 @@
isa = XCBuildConfiguration;
baseConfigurationReference = B44F4C7012EB4623C0D33E3A /* Pods-LabelSwitch_Tests.debug.xcconfig */;
buildSettings = {
FRAMEWORK_SEARCH_PATHS = (
"$(SDKROOT)/Developer/Library/Frameworks",
"$(inherited)",
);
FRAMEWORK_SEARCH_PATHS = "$(inherited)";
GCC_PREPROCESSOR_DEFINITIONS = (
"DEBUG=1",
"$(inherited)",
);
INFOPLIST_FILE = Tests/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 10.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = "org.cocoapods.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
SWIFT_VERSION = 4.0;
SWIFT_VERSION = 5.0;
};
name = Debug;
};
@@ -579,16 +530,13 @@
isa = XCBuildConfiguration;
baseConfigurationReference = 3FCE599881BA9C988E5C908E /* Pods-LabelSwitch_Tests.release.xcconfig */;
buildSettings = {
FRAMEWORK_SEARCH_PATHS = (
"$(SDKROOT)/Developer/Library/Frameworks",
"$(inherited)",
);
FRAMEWORK_SEARCH_PATHS = "$(inherited)";
INFOPLIST_FILE = Tests/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 10.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = "org.cocoapods.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
SWIFT_VERSION = 4.0;
SWIFT_VERSION = 5.0;
};
name = Release;
};
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0900"
LastUpgradeVersion = "1140"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
@@ -40,8 +40,16 @@
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
language = ""
shouldUseLaunchSchemeArgsEnv = "YES">
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "607FACCF1AFB9204008FA782"
BuildableName = "LabelSwitch_Example.app"
BlueprintName = "LabelSwitch_Example"
ReferencedContainer = "container:LabelSwitch.xcodeproj">
</BuildableReference>
</MacroExpansion>
<Testables>
<TestableReference
skipped = "NO">
@@ -54,23 +62,11 @@
</BuildableReference>
</TestableReference>
</Testables>
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "607FACCF1AFB9204008FA782"
BuildableName = "LabelSwitch_Example.app"
BlueprintName = "LabelSwitch_Example"
ReferencedContainer = "container:LabelSwitch.xcodeproj">
</BuildableReference>
</MacroExpansion>
<AdditionalOptions>
</AdditionalOptions>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
language = ""
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
@@ -87,8 +83,6 @@
ReferencedContainer = "container:LabelSwitch.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
<AdditionalOptions>
</AdditionalOptions>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
+1 -1
View File
@@ -14,7 +14,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.
return true
}
+34 -37
View File
@@ -1,11 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="14113" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="vXZ-lx-hvc">
<device id="retina4_7" orientation="portrait">
<adaptation id="fullscreen"/>
</device>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="16096" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="vXZ-lx-hvc">
<device id="retina6_5" orientation="portrait" appearance="light"/>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="14088"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="16087"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<scenes>
@@ -18,42 +16,41 @@
<viewControllerLayoutGuide type="bottom" id="2fi-mo-0CV"/>
</layoutGuides>
<view key="view" contentMode="scaleToFill" id="kh9-bI-dsS">
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
<rect key="frame" x="0.0" y="0.0" width="414" height="896"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<subviews>
<stackView opaque="NO" contentMode="scaleToFill" ambiguous="YES" axis="vertical" translatesAutoresizingMaskIntoConstraints="NO" id="wIm-yi-cLv">
<rect key="frame" x="83" y="264" width="173" height="128"/>
<subviews>
<view contentMode="scaleToFill" ambiguous="YES" translatesAutoresizingMaskIntoConstraints="NO" id="PGQ-i0-4O4" customClass="LabelSwitch" customModule="LabelSwitch">
<rect key="frame" x="0.0" y="0.0" width="173" height="128"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<userDefinedRuntimeAttributes>
<userDefinedRuntimeAttribute type="color" keyPath="lBackColor">
<color key="value" red="1" green="0.90876896409999997" blue="0.13431931529999999" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</userDefinedRuntimeAttribute>
<userDefinedRuntimeAttribute type="color" keyPath="rBackColor">
<color key="value" red="0.34343534650000002" green="0.44993422370000002" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</userDefinedRuntimeAttribute>
<userDefinedRuntimeAttribute type="color" keyPath="lTextColor">
<color key="value" white="1" alpha="1" colorSpace="calibratedWhite"/>
</userDefinedRuntimeAttribute>
<userDefinedRuntimeAttribute type="color" keyPath="rTextColor">
<color key="value" white="1" alpha="1" colorSpace="calibratedWhite"/>
</userDefinedRuntimeAttribute>
<userDefinedRuntimeAttribute type="string" keyPath="lText" value="Left"/>
<userDefinedRuntimeAttribute type="string" keyPath="rText" value="Right"/>
<userDefinedRuntimeAttribute type="number" keyPath="fontSize">
<real key="value" value="20"/>
</userDefinedRuntimeAttribute>
</userDefinedRuntimeAttributes>
</view>
</subviews>
</stackView>
<view contentMode="scaleToFill" ambiguous="YES" translatesAutoresizingMaskIntoConstraints="NO" id="PGQ-i0-4O4" customClass="LabelSwitch" customModule="LabelSwitch">
<rect key="frame" x="155" y="94" width="104" height="65"/>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<constraints>
<constraint firstAttribute="height" relation="greaterThanOrEqual" id="60m-DS-uVG"/>
<constraint firstAttribute="width" relation="greaterThanOrEqual" id="uFB-54-Byd"/>
</constraints>
<userDefinedRuntimeAttributes>
<userDefinedRuntimeAttribute type="color" keyPath="lBackColor">
<color key="value" red="1" green="0.90876896409999997" blue="0.13431931529999999" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</userDefinedRuntimeAttribute>
<userDefinedRuntimeAttribute type="color" keyPath="rBackColor">
<color key="value" red="0.34343534650000002" green="0.44993422370000002" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</userDefinedRuntimeAttribute>
<userDefinedRuntimeAttribute type="color" keyPath="lTextColor">
<color key="value" white="1" alpha="1" colorSpace="calibratedWhite"/>
</userDefinedRuntimeAttribute>
<userDefinedRuntimeAttribute type="color" keyPath="rTextColor">
<color key="value" white="1" alpha="1" colorSpace="calibratedWhite"/>
</userDefinedRuntimeAttribute>
<userDefinedRuntimeAttribute type="string" keyPath="lText" value="Left"/>
<userDefinedRuntimeAttribute type="string" keyPath="rText" value="Right"/>
<userDefinedRuntimeAttribute type="number" keyPath="fontSize">
<real key="value" value="20"/>
</userDefinedRuntimeAttribute>
</userDefinedRuntimeAttributes>
</view>
</subviews>
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<constraints>
<constraint firstItem="wIm-yi-cLv" firstAttribute="centerX" secondItem="kh9-bI-dsS" secondAttribute="centerX" id="KYI-CP-o7e"/>
<constraint firstItem="wIm-yi-cLv" firstAttribute="centerY" secondItem="kh9-bI-dsS" secondAttribute="centerY" id="dBS-sy-z63"/>
<constraint firstItem="PGQ-i0-4O4" firstAttribute="centerX" secondItem="kh9-bI-dsS" secondAttribute="centerX" id="3Sz-f4-gvz"/>
<constraint firstItem="PGQ-i0-4O4" firstAttribute="top" secondItem="jyV-Pf-zRb" secondAttribute="bottom" constant="50" id="KSh-sO-syx"/>
</constraints>
</view>
<connections>
@@ -62,7 +59,7 @@
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="x5A-6p-PRh" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="117.59999999999999" y="118.29085457271366"/>
<point key="canvasLocation" x="33" y="71"/>
</scene>
</scenes>
</document>
+4 -10
View File
@@ -50,19 +50,13 @@ class ViewController: UIViewController {
let imageLabelSwitch = LabelSwitch(center: CGPoint(x: view.center.x, y: view.center.y + 200), leftConfig: ls3, rightConfig: rs3, defaultState: .L)
view.addSubview(imageLabelSwitch)
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
}
extension ViewController: LabelSwitchDelegate {
func switchChangToState(_ state: LabelSwitchState) {
switch state {
case .L: print("circle on left")
case .R: print("circle on right")
func switchChangToState(sender: LabelSwitch) {
switch sender.curState {
case .L: print("left")
case .R: print("right")
}
}
}
+4 -4
View File
@@ -1,16 +1,16 @@
PODS:
- LabelSwitch (0.1.4)
- LabelSwitch (0.1.7)
DEPENDENCIES:
- LabelSwitch (from `../`)
EXTERNAL SOURCES:
LabelSwitch:
:path: ../
:path: "../"
SPEC CHECKSUMS:
LabelSwitch: 6ec30e04812990a858178810129024c8bdb7dbb3
LabelSwitch: 06333d13e4050d3af7832df872ec3a425bb7dcf1
PODFILE CHECKSUM: a898de11b0f271336544f6e30dfc02c11c75244a
COCOAPODS: 1.4.0
COCOAPODS: 1.5.3
+2 -2
View File
@@ -1,6 +1,6 @@
{
"name": "LabelSwitch",
"version": "0.1.4",
"version": "0.1.7",
"summary": "Switch with label in background",
"description": "TODO: Add long description of the pod here.",
"homepage": "https://github.com/Cookiezby/LabelSwitch",
@@ -13,7 +13,7 @@
},
"source": {
"git": "https://github.com/Cookiezby/LabelSwitch.git",
"tag": "0.1.4"
"tag": "0.1.7"
},
"platforms": {
"ios": "9.0"
+4 -4
View File
@@ -1,16 +1,16 @@
PODS:
- LabelSwitch (0.1.4)
- LabelSwitch (0.1.7)
DEPENDENCIES:
- LabelSwitch (from `../`)
EXTERNAL SOURCES:
LabelSwitch:
:path: ../
:path: "../"
SPEC CHECKSUMS:
LabelSwitch: 6ec30e04812990a858178810129024c8bdb7dbb3
LabelSwitch: 06333d13e4050d3af7832df872ec3a425bb7dcf1
PODFILE CHECKSUM: a898de11b0f271336544f6e30dfc02c11c75244a
COCOAPODS: 1.4.0
COCOAPODS: 1.5.3
File diff suppressed because it is too large Load Diff
@@ -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 -1
View File
@@ -15,7 +15,7 @@
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>0.1.4</string>
<string>0.1.7</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
@@ -1,6 +1,5 @@
CONFIGURATION_BUILD_DIR = ${PODS_CONFIGURATION_BUILD_DIR}/LabelSwitch
GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1
HEADER_SEARCH_PATHS = "${PODS_ROOT}/Headers/Private" "${PODS_ROOT}/Headers/Public"
OTHER_SWIFT_FLAGS = $(inherited) "-D" "COCOAPODS"
PODS_BUILD_DIR = ${BUILD_DIR}
PODS_CONFIGURATION_BUILD_DIR = ${PODS_BUILD_DIR}/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)
@@ -1,9 +1,18 @@
#!/bin/sh
set -e
set -u
set -o pipefail
if [ -z ${FRAMEWORKS_FOLDER_PATH+x} ]; then
# If FRAMEWORKS_FOLDER_PATH is not set, then there's nowhere for us to copy
# frameworks to, so exit 0 (signalling the script phase was successful).
exit 0
fi
echo "mkdir -p ${CONFIGURATION_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}"
mkdir -p "${CONFIGURATION_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}"
COCOAPODS_PARALLEL_CODE_SIGN="${COCOAPODS_PARALLEL_CODE_SIGN:-false}"
SWIFT_STDLIB_PATH="${DT_TOOLCHAIN_DIR}/usr/lib/swift/${PLATFORM_NAME}"
# Used as a return value for each invocation of `strip_invalid_archs` function.
@@ -92,10 +101,10 @@ install_dsym() {
# Signs a framework with the provided identity
code_sign_if_enabled() {
if [ -n "${EXPANDED_CODE_SIGN_IDENTITY}" -a "${CODE_SIGNING_REQUIRED}" != "NO" -a "${CODE_SIGNING_ALLOWED}" != "NO" ]; then
if [ -n "${EXPANDED_CODE_SIGN_IDENTITY}" -a "${CODE_SIGNING_REQUIRED:-}" != "NO" -a "${CODE_SIGNING_ALLOWED}" != "NO" ]; then
# Use the current code_sign_identitiy
echo "Code Signing $1 with Identity ${EXPANDED_CODE_SIGN_IDENTITY_NAME}"
local code_sign_cmd="/usr/bin/codesign --force --sign ${EXPANDED_CODE_SIGN_IDENTITY} ${OTHER_CODE_SIGN_FLAGS} --preserve-metadata=identifier,entitlements '$1'"
local code_sign_cmd="/usr/bin/codesign --force --sign ${EXPANDED_CODE_SIGN_IDENTITY} ${OTHER_CODE_SIGN_FLAGS:-} --preserve-metadata=identifier,entitlements '$1'"
if [ "${COCOAPODS_PARALLEL_CODE_SIGN}" == "true" ]; then
code_sign_cmd="$code_sign_cmd &"
@@ -1,5 +1,13 @@
#!/bin/sh
set -e
set -u
set -o pipefail
if [ -z ${UNLOCALIZED_RESOURCES_FOLDER_PATH+x} ]; then
# If UNLOCALIZED_RESOURCES_FOLDER_PATH is not set, then there's nowhere for us to copy
# resources to, so exit 0 (signalling the script phase was successful).
exit 0
fi
mkdir -p "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}"
@@ -12,7 +20,7 @@ XCASSET_FILES=()
# was originally proposed here: https://lists.samba.org/archive/rsync/2008-February/020158.html
RSYNC_PROTECT_TMP_FILES=(--filter "P .*.??????")
case "${TARGETED_DEVICE_FAMILY}" in
case "${TARGETED_DEVICE_FAMILY:-}" in
1,2)
TARGET_DEVICE_ARGS="--target-device ipad --target-device iphone"
;;
@@ -92,7 +100,7 @@ if [[ "${ACTION}" == "install" ]] && [[ "${SKIP_INSTALL}" == "NO" ]]; then
fi
rm -f "$RESOURCES_TO_COPY"
if [[ -n "${WRAPPER_EXTENSION}" ]] && [ "`xcrun --find actool`" ] && [ -n "$XCASSET_FILES" ]
if [[ -n "${WRAPPER_EXTENSION}" ]] && [ "`xcrun --find actool`" ] && [ -n "${XCASSET_FILES:-}" ]
then
# Find all other xcassets (this unfortunately includes those of path pods and other targets).
OTHER_XCASSETS=$(find "$PWD" -iname "*.xcassets" -type d)
@@ -102,5 +110,9 @@ then
fi
done <<<"$OTHER_XCASSETS"
printf "%s\0" "${XCASSET_FILES[@]}" | xargs -0 xcrun actool --output-format human-readable-text --notices --warnings --platform "${PLATFORM_NAME}" --minimum-deployment-target "${!DEPLOYMENT_TARGET_SETTING_NAME}" ${TARGET_DEVICE_ARGS} --compress-pngs --compile "${BUILT_PRODUCTS_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}"
if [ -z ${ASSETCATALOG_COMPILER_APPICON_NAME+x} ]; then
printf "%s\0" "${XCASSET_FILES[@]}" | xargs -0 xcrun actool --output-format human-readable-text --notices --warnings --platform "${PLATFORM_NAME}" --minimum-deployment-target "${!DEPLOYMENT_TARGET_SETTING_NAME}" ${TARGET_DEVICE_ARGS} --compress-pngs --compile "${BUILT_PRODUCTS_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}"
else
printf "%s\0" "${XCASSET_FILES[@]}" | xargs -0 xcrun actool --output-format human-readable-text --notices --warnings --platform "${PLATFORM_NAME}" --minimum-deployment-target "${!DEPLOYMENT_TARGET_SETTING_NAME}" ${TARGET_DEVICE_ARGS} --compress-pngs --compile "${BUILT_PRODUCTS_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}" --app-icon "${ASSETCATALOG_COMPILER_APPICON_NAME}" --output-partial-info-plist "${TARGET_TEMP_DIR}/assetcatalog_generated_info_cocoapods.plist"
fi
fi
@@ -1,9 +1,18 @@
#!/bin/sh
set -e
set -u
set -o pipefail
if [ -z ${FRAMEWORKS_FOLDER_PATH+x} ]; then
# If FRAMEWORKS_FOLDER_PATH is not set, then there's nowhere for us to copy
# frameworks to, so exit 0 (signalling the script phase was successful).
exit 0
fi
echo "mkdir -p ${CONFIGURATION_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}"
mkdir -p "${CONFIGURATION_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}"
COCOAPODS_PARALLEL_CODE_SIGN="${COCOAPODS_PARALLEL_CODE_SIGN:-false}"
SWIFT_STDLIB_PATH="${DT_TOOLCHAIN_DIR}/usr/lib/swift/${PLATFORM_NAME}"
# Used as a return value for each invocation of `strip_invalid_archs` function.
@@ -92,10 +101,10 @@ install_dsym() {
# Signs a framework with the provided identity
code_sign_if_enabled() {
if [ -n "${EXPANDED_CODE_SIGN_IDENTITY}" -a "${CODE_SIGNING_REQUIRED}" != "NO" -a "${CODE_SIGNING_ALLOWED}" != "NO" ]; then
if [ -n "${EXPANDED_CODE_SIGN_IDENTITY}" -a "${CODE_SIGNING_REQUIRED:-}" != "NO" -a "${CODE_SIGNING_ALLOWED}" != "NO" ]; then
# Use the current code_sign_identitiy
echo "Code Signing $1 with Identity ${EXPANDED_CODE_SIGN_IDENTITY_NAME}"
local code_sign_cmd="/usr/bin/codesign --force --sign ${EXPANDED_CODE_SIGN_IDENTITY} ${OTHER_CODE_SIGN_FLAGS} --preserve-metadata=identifier,entitlements '$1'"
local code_sign_cmd="/usr/bin/codesign --force --sign ${EXPANDED_CODE_SIGN_IDENTITY} ${OTHER_CODE_SIGN_FLAGS:-} --preserve-metadata=identifier,entitlements '$1'"
if [ "${COCOAPODS_PARALLEL_CODE_SIGN}" == "true" ]; then
code_sign_cmd="$code_sign_cmd &"
@@ -1,5 +1,13 @@
#!/bin/sh
set -e
set -u
set -o pipefail
if [ -z ${UNLOCALIZED_RESOURCES_FOLDER_PATH+x} ]; then
# If UNLOCALIZED_RESOURCES_FOLDER_PATH is not set, then there's nowhere for us to copy
# resources to, so exit 0 (signalling the script phase was successful).
exit 0
fi
mkdir -p "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}"
@@ -12,7 +20,7 @@ XCASSET_FILES=()
# was originally proposed here: https://lists.samba.org/archive/rsync/2008-February/020158.html
RSYNC_PROTECT_TMP_FILES=(--filter "P .*.??????")
case "${TARGETED_DEVICE_FAMILY}" in
case "${TARGETED_DEVICE_FAMILY:-}" in
1,2)
TARGET_DEVICE_ARGS="--target-device ipad --target-device iphone"
;;
@@ -92,7 +100,7 @@ if [[ "${ACTION}" == "install" ]] && [[ "${SKIP_INSTALL}" == "NO" ]]; then
fi
rm -f "$RESOURCES_TO_COPY"
if [[ -n "${WRAPPER_EXTENSION}" ]] && [ "`xcrun --find actool`" ] && [ -n "$XCASSET_FILES" ]
if [[ -n "${WRAPPER_EXTENSION}" ]] && [ "`xcrun --find actool`" ] && [ -n "${XCASSET_FILES:-}" ]
then
# Find all other xcassets (this unfortunately includes those of path pods and other targets).
OTHER_XCASSETS=$(find "$PWD" -iname "*.xcassets" -type d)
@@ -102,5 +110,9 @@ then
fi
done <<<"$OTHER_XCASSETS"
printf "%s\0" "${XCASSET_FILES[@]}" | xargs -0 xcrun actool --output-format human-readable-text --notices --warnings --platform "${PLATFORM_NAME}" --minimum-deployment-target "${!DEPLOYMENT_TARGET_SETTING_NAME}" ${TARGET_DEVICE_ARGS} --compress-pngs --compile "${BUILT_PRODUCTS_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}"
if [ -z ${ASSETCATALOG_COMPILER_APPICON_NAME+x} ]; then
printf "%s\0" "${XCASSET_FILES[@]}" | xargs -0 xcrun actool --output-format human-readable-text --notices --warnings --platform "${PLATFORM_NAME}" --minimum-deployment-target "${!DEPLOYMENT_TARGET_SETTING_NAME}" ${TARGET_DEVICE_ARGS} --compress-pngs --compile "${BUILT_PRODUCTS_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}"
else
printf "%s\0" "${XCASSET_FILES[@]}" | xargs -0 xcrun actool --output-format human-readable-text --notices --warnings --platform "${PLATFORM_NAME}" --minimum-deployment-target "${!DEPLOYMENT_TARGET_SETTING_NAME}" ${TARGET_DEVICE_ARGS} --compress-pngs --compile "${BUILT_PRODUCTS_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}" --app-icon "${ASSETCATALOG_COMPILER_APPICON_NAME}" --output-partial-info-plist "${TARGET_TEMP_DIR}/assetcatalog_generated_info_cocoapods.plist"
fi
fi
+2 -13
View File
@@ -8,24 +8,13 @@
Pod::Spec.new do |s|
s.name = 'LabelSwitch'
s.version = '0.1.4'
s.version = '0.1.7'
s.summary = 'Switch with label in background'
# This description is used to generate tags and improve search results.
# * Think: What does it do? Why did you write it? What is the focus?
# * Try to keep it short, snappy and to the point.
# * Write the description between the DESC delimiters below.
# * Finally, don't worry about the indent, CocoaPods strips it!
s.description = <<-DESC
TODO: Add long description of the pod here.
DESC
s.homepage = 'https://github.com/Cookiezby/LabelSwitch'
s.license = { :type => 'MIT', :file => 'LICENSE' }
s.author = { 'cookiezby@gmail.com' => 'cookiezby@gmail.com' }
s.source = { :git => 'https://github.com/Cookiezby/LabelSwitch.git', :tag => s.version.to_s }
s.ios.deployment_target = '9.0'
s.ios.deployment_target = '10.0'
s.source_files = 'LabelSwitch/Classes/**/*'
+32 -20
View File
@@ -10,7 +10,7 @@ import Foundation
import UIKit
public protocol LabelSwitchDelegate : class {
func switchChangToState(_ state: LabelSwitchState) -> Void
func switchChangToState(sender: LabelSwitch) -> Void
}
private class LabelSwitchPart {
@@ -88,17 +88,17 @@ private class LabelSwitchPart {
private var switchConfigL: LabelSwitchConfig! {
didSet {
stateL.backgroundColor = switchConfigL.backgroundColor
stateL.backgroundColor = switchConfigL.backgroundColor
leftPart.setConfig(switchConfigL)
}
}
private var switchConfigR: LabelSwitchConfig! {
didSet {
stateR.backgroundColor = switchConfigR.backgroundColor
stateR.backgroundColor = switchConfigR.backgroundColor
rightPart.setConfig(switchConfigR)
}
}
private var edge: CGFloat = 0
private let circlePadding: CGFloat
private let minimumSize: CGSize
@@ -133,10 +133,10 @@ private class LabelSwitchPart {
public var fullSizeTapEnabled: Bool = false {
didSet{
if fullSizeTapEnabled {
fullSizeTapGesture = UITapGestureRecognizer(target: self, action: #selector(switchTaped(sender:)))
fullSizeTapGesture = UITapGestureRecognizer(target: self, action: #selector(switchTapped(sender:)))
addGestureRecognizer(fullSizeTapGesture!)
} else {
fullSizeTapGesture?.removeTarget(self, action: #selector(switchTaped(sender:)))
fullSizeTapGesture?.removeTarget(self, action: #selector(switchTapped(sender:)))
fullSizeTapGesture = nil
}
}
@@ -151,14 +151,21 @@ private class LabelSwitchPart {
setupCircle()
}
}
/// Enable the swith
public var isEnable: Bool = true
override public convenience init(frame: CGRect) {
self.init(center: .zero, leftConfig: .defaultLeft, rightConfig: .defaultRight)
}
public init(center: CGPoint,
leftConfig: LabelSwitchConfig,
rightConfig: LabelSwitchConfig,
circlePadding: CGFloat = 1,
minimumSize: CGSize = .zero,
defaultState: LabelSwitchState = .L) {
self.circlePadding = circlePadding
self.minimumSize = minimumSize
self.curState = defaultState
@@ -169,7 +176,7 @@ private class LabelSwitchPart {
setConfig(left: leftConfig, right: rightConfig)
updateUI()
}
private func updateUI() {
calculateSize()
switch curState {
@@ -201,7 +208,7 @@ private class LabelSwitchPart {
stateR.circleFrame = CGRect(origin: CGPoint(x: bounds.width - diameter - circlePadding, y: circlePadding),
size: circleSize)
/// Add the touch event to the circle view
circleView.addGestureRecognizer(UITapGestureRecognizer(target: self, action: #selector(switchTaped(sender:))))
circleView.addGestureRecognizer(UITapGestureRecognizer(target: self, action: #selector(switchTapped(sender:))))
}
/// Set the label's frame and color
@@ -228,16 +235,13 @@ private class LabelSwitchPart {
}
/// Called when the circle is touched
@objc
func switchTaped(sender: Any) {
UIView.animate(withDuration: 0.3) {
switch self.curState {
case .L:
self.delegate?.switchChangToState(.R)
self.curState = .R
case .R:
self.delegate?.switchChangToState(.L)
self.curState = .L
@objc private func switchTapped(sender: Any) {
guard isEnable else { return }
UIView.animate(withDuration: 0.3, animations: {
self.curState.flip()
}) { (completed) in
if completed {
self.delegate?.switchChangToState(sender: self)
}
}
}
@@ -254,42 +258,50 @@ private class LabelSwitchPart {
/// For InterfaceBuilder
@IBInspectable var lBackColor: UIColor = .white {
didSet{
guard switchConfigL != nil else { return }
switchConfigL.backgroundColor = lBackColor
}
}
@IBInspectable var rBackColor: UIColor = .white {
didSet{
guard switchConfigR != nil else { return }
switchConfigR.backgroundColor = rBackColor
}
}
@IBInspectable var lTextColor: UIColor = .white {
didSet{
guard switchConfigL != nil else { return }
switchConfigL.textColor = lTextColor
}
}
@IBInspectable var rTextColor: UIColor = .white {
didSet{
guard switchConfigR != nil else { return }
switchConfigR.textColor = rTextColor
}
}
@IBInspectable var lText: String = "" {
didSet{
guard switchConfigL != nil else { return }
switchConfigL.text = lText
}
}
@IBInspectable var rText: String = "" {
didSet{
guard switchConfigR != nil else { return }
switchConfigR.text = rText
}
}
@IBInspectable var fontSize: CGFloat = 10 {
didSet{
guard switchConfigR != nil else { return }
guard switchConfigL != nil else { return }
switchConfigL.font = .systemFont(ofSize: fontSize)
switchConfigR.font = .systemFont(ofSize: fontSize)
}
@@ -55,6 +55,15 @@ public struct LabelSwitchConfig {
public enum LabelSwitchState {
case L
case R
mutating func flip() {
switch self {
case .L:
self = .R
case .R:
self = .L
}
}
}
+1 -1
View File
@@ -13,7 +13,7 @@ struct LabelSwitchPartState {
struct LabelSwitchUIState {
var backgroundColor: UIColor = .clear
var circleFrame:CGRect = .zero
var circleFrame: CGRect = .zero
var leftPartState = LabelSwitchPartState()
var rightPartState = LabelSwitchPartState()
}
+19 -16
View File
@@ -1,6 +1,6 @@
![LabeSwitch](https://github.com/Tobaloidee/LabelSwitch/blob/master/logo/logotype-a-05.png)
[![CI Status](http://img.shields.io/travis/Cookiezby/LabelSwitch.svg?style=flat)](https://travis-ci.org/Cookiezby/LabelSwitch)
[![Build Status](https://travis-ci.org/Cookiezby/LabelSwitch.svg?branch=master)](https://travis-ci.org/Cookiezby/LabelSwitch)
[![Version](https://img.shields.io/cocoapods/v/LabelSwitch.svg?style=flat)](http://cocoapods.org/pods/LabelSwitch)
[![License](https://img.shields.io/cocoapods/l/LabelSwitch.svg?style=flat)](http://cocoapods.org/pods/LabelSwitch)
[![Platform](https://img.shields.io/cocoapods/p/LabelSwitch.svg?style=flat)](http://cocoapods.org/pods/LabelSwitch)
@@ -18,21 +18,25 @@ pod 'LabelSwitch'
## Usage
You can create the view through code or InterfaceBuilder
**You can create the view through code or InterfaceBuilder**
### Use with Interface Builder
Set the position constarint for the switch, and set the width and height constraint to larger than zero.
### Use with code
```swift
let ls = LabelSwtichSetting(text: "Text1",
textColor: .white,
font: UIFont.boldSystemFont(ofSize: 15),
backgroundColor: .red)
let ls = LabelSwitchConfig(text: "Text1",
textColor: .white,
font: UIFont.boldSystemFont(ofSize: 15),
backgroundColor: .red)
let rs = LabelSwtichSetting(text: "Text2",
textColor: .white,
font: UIFont.boldSystemFont(ofSize: 20),
backgroundColor: .green)
let rs = LabelSwitchConfig(text: "Text2",
textColor: .white,
font: UIFont.boldSystemFont(ofSize: 20),
backgroundColor: .green)
// Set the default state of the switch,
let labelSwitch = LabelSwitch(center: .zero, leftSetting: ls, rightSetting: rs, defaultState: .L)
let labelSwitch = LabelSwitch(center: .zero, leftConfig: ls, rightConfig: rs)
// Set the appearance of the circle button
labelSwitch.circleShadow = false
@@ -45,16 +49,15 @@ labelSwitch.fullSizeTapEnabled = true
labelSwitch.delegate = self
extension ViewController: LabelSwitchDelegate {
func switchChangToState(_ state: SwitchState) {
switch state {
case .L: print("circle on left")
case .R: print("circle on right")
func switchChangToState(sender: LabelSwitch) {
switch sender.curState {
case .L: print("left state")
case .R: print("right state")
}
}
}
```
you can also make the switch background to be image or gradient color
```
// gradient color