diff --git a/.gitignore b/.gitignore
index 8c205a8..3684412 100644
--- a/.gitignore
+++ b/.gitignore
@@ -2,3 +2,4 @@ ScrollableSegmentedControl.xcodeproj/project.xcworkspace/xcuserdata
ScrollableSegmentedControl.xcodeproj/xcuserdata
Demo/ScrollableSegmentedControlDemo/ScrollableSegmentedControlDemo.xcodeproj/project.xcworkspace/xcuserdata
Demo/ScrollableSegmentedControlDemo/ScrollableSegmentedControlDemo.xcodeproj/xcuserdata
+.swiftpm
\ No newline at end of file
diff --git a/.swift-version b/.swift-version
deleted file mode 100644
index 5186d07..0000000
--- a/.swift-version
+++ /dev/null
@@ -1 +0,0 @@
-4.0
diff --git a/Demo/ScrollableSegmentedControlDemo/ScrollableSegmentedControlDemo.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/Demo/ScrollableSegmentedControlDemo/ScrollableSegmentedControlDemo.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist
new file mode 100644
index 0000000..18d9810
--- /dev/null
+++ b/Demo/ScrollableSegmentedControlDemo/ScrollableSegmentedControlDemo.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist
@@ -0,0 +1,8 @@
+
+
+
+
+ IDEDidComputeMac32BitWarning
+
+
+
diff --git a/Package.swift b/Package.swift
new file mode 100644
index 0000000..7b249a9
--- /dev/null
+++ b/Package.swift
@@ -0,0 +1,24 @@
+// swift-tools-version:5.5
+// The swift-tools-version declares the minimum version of Swift required to build this package.
+
+import PackageDescription
+
+let package = Package(
+ name: "ScrollableSegmentedControl",
+ products: [
+ // Products define the executables and libraries a package produces, and make them visible to other packages.
+ .library(
+ name: "ScrollableSegmentedControl",
+ targets: ["ScrollableSegmentedControl"]),
+ ],
+ targets: [
+ // Targets are the basic building blocks of a package. A target can define a module or a test suite.
+ // Targets can depend on other targets in this package, and on products in packages this package depends on.
+ .target(
+ name: "ScrollableSegmentedControl",
+ dependencies: []),
+ .testTarget(
+ name: "ScrollableSegmentedControlTests",
+ dependencies: ["ScrollableSegmentedControl"]),
+ ]
+)
diff --git a/ScrollableSegmentedControl.podspec b/ScrollableSegmentedControl.podspec
deleted file mode 100644
index f9d9bc0..0000000
--- a/ScrollableSegmentedControl.podspec
+++ /dev/null
@@ -1,14 +0,0 @@
-Pod::Spec.new do |s|
- s.name = 'ScrollableSegmentedControl'
- s.version = '1.3.0'
- s.license = 'MIT'
- s.summary = 'Scrollable Segmented Control for when UISegmentedControl is not sufficient'
- s.homepage = 'https://github.com/GocePetrovski/ScrollableSegmentedControl'
- s.social_media_url = 'http://twitter.com/GocePetrovski'
- s.authors = { 'Goce Petrovski' => 'goce.petrovski@gmail.com' }
- s.source = { :git => 'https://github.com/GocePetrovski/ScrollableSegmentedControl.git', :tag => s.version }
-
- s.platform = :ios, '9.0'
-
- s.source_files = 'ScrollableSegmentedControl/*.swift'
-end
diff --git a/ScrollableSegmentedControl.xcodeproj/project.pbxproj b/ScrollableSegmentedControl.xcodeproj/project.pbxproj
deleted file mode 100644
index cdcfda8..0000000
--- a/ScrollableSegmentedControl.xcodeproj/project.pbxproj
+++ /dev/null
@@ -1,444 +0,0 @@
-// !$*UTF8*$!
-{
- archiveVersion = 1;
- classes = {
- };
- objectVersion = 46;
- objects = {
-
-/* Begin PBXBuildFile section */
- CD078DA71DD4B5B30083F53F /* ScrollableSegmentedControl.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = CD078D9D1DD4B5B30083F53F /* ScrollableSegmentedControl.framework */; };
- CD078DAC1DD4B5B30083F53F /* ScrollableSegmentedControlTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = CD078DAB1DD4B5B30083F53F /* ScrollableSegmentedControlTests.swift */; };
- CD078DAE1DD4B5B30083F53F /* ScrollableSegmentedControl.h in Headers */ = {isa = PBXBuildFile; fileRef = CD078DA01DD4B5B30083F53F /* ScrollableSegmentedControl.h */; settings = {ATTRIBUTES = (Public, ); }; };
- CD078DB81DD4B69F0083F53F /* ScrollableSegmentedControl.swift in Sources */ = {isa = PBXBuildFile; fileRef = CD078DB71DD4B69F0083F53F /* ScrollableSegmentedControl.swift */; };
-/* End PBXBuildFile section */
-
-/* Begin PBXContainerItemProxy section */
- CD078DA81DD4B5B30083F53F /* PBXContainerItemProxy */ = {
- isa = PBXContainerItemProxy;
- containerPortal = CD078D941DD4B5B30083F53F /* Project object */;
- proxyType = 1;
- remoteGlobalIDString = CD078D9C1DD4B5B30083F53F;
- remoteInfo = ScrollableSegmentedControl;
- };
-/* End PBXContainerItemProxy section */
-
-/* Begin PBXFileReference section */
- CD078D9D1DD4B5B30083F53F /* ScrollableSegmentedControl.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = ScrollableSegmentedControl.framework; sourceTree = BUILT_PRODUCTS_DIR; };
- CD078DA01DD4B5B30083F53F /* ScrollableSegmentedControl.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ScrollableSegmentedControl.h; sourceTree = ""; };
- CD078DA11DD4B5B30083F53F /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; };
- CD078DA61DD4B5B30083F53F /* ScrollableSegmentedControlTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = ScrollableSegmentedControlTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
- CD078DAB1DD4B5B30083F53F /* ScrollableSegmentedControlTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ScrollableSegmentedControlTests.swift; sourceTree = ""; };
- CD078DAD1DD4B5B30083F53F /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; };
- CD078DB71DD4B69F0083F53F /* ScrollableSegmentedControl.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ScrollableSegmentedControl.swift; sourceTree = ""; };
-/* End PBXFileReference section */
-
-/* Begin PBXFrameworksBuildPhase section */
- CD078D991DD4B5B30083F53F /* Frameworks */ = {
- isa = PBXFrameworksBuildPhase;
- buildActionMask = 2147483647;
- files = (
- );
- runOnlyForDeploymentPostprocessing = 0;
- };
- CD078DA31DD4B5B30083F53F /* Frameworks */ = {
- isa = PBXFrameworksBuildPhase;
- buildActionMask = 2147483647;
- files = (
- CD078DA71DD4B5B30083F53F /* ScrollableSegmentedControl.framework in Frameworks */,
- );
- runOnlyForDeploymentPostprocessing = 0;
- };
-/* End PBXFrameworksBuildPhase section */
-
-/* Begin PBXGroup section */
- CD078D931DD4B5B30083F53F = {
- isa = PBXGroup;
- children = (
- CD078D9F1DD4B5B30083F53F /* ScrollableSegmentedControl */,
- CD078DAA1DD4B5B30083F53F /* ScrollableSegmentedControlTests */,
- CD078D9E1DD4B5B30083F53F /* Products */,
- );
- sourceTree = "";
- };
- CD078D9E1DD4B5B30083F53F /* Products */ = {
- isa = PBXGroup;
- children = (
- CD078D9D1DD4B5B30083F53F /* ScrollableSegmentedControl.framework */,
- CD078DA61DD4B5B30083F53F /* ScrollableSegmentedControlTests.xctest */,
- );
- name = Products;
- sourceTree = "";
- };
- CD078D9F1DD4B5B30083F53F /* ScrollableSegmentedControl */ = {
- isa = PBXGroup;
- children = (
- CD078DB71DD4B69F0083F53F /* ScrollableSegmentedControl.swift */,
- CD078DA01DD4B5B30083F53F /* ScrollableSegmentedControl.h */,
- CD078DA11DD4B5B30083F53F /* Info.plist */,
- );
- path = ScrollableSegmentedControl;
- sourceTree = "";
- };
- CD078DAA1DD4B5B30083F53F /* ScrollableSegmentedControlTests */ = {
- isa = PBXGroup;
- children = (
- CD078DAB1DD4B5B30083F53F /* ScrollableSegmentedControlTests.swift */,
- CD078DAD1DD4B5B30083F53F /* Info.plist */,
- );
- path = ScrollableSegmentedControlTests;
- sourceTree = "";
- };
-/* End PBXGroup section */
-
-/* Begin PBXHeadersBuildPhase section */
- CD078D9A1DD4B5B30083F53F /* Headers */ = {
- isa = PBXHeadersBuildPhase;
- buildActionMask = 2147483647;
- files = (
- CD078DAE1DD4B5B30083F53F /* ScrollableSegmentedControl.h in Headers */,
- );
- runOnlyForDeploymentPostprocessing = 0;
- };
-/* End PBXHeadersBuildPhase section */
-
-/* Begin PBXNativeTarget section */
- CD078D9C1DD4B5B30083F53F /* ScrollableSegmentedControl */ = {
- isa = PBXNativeTarget;
- buildConfigurationList = CD078DB11DD4B5B30083F53F /* Build configuration list for PBXNativeTarget "ScrollableSegmentedControl" */;
- buildPhases = (
- CD078D981DD4B5B30083F53F /* Sources */,
- CD078D991DD4B5B30083F53F /* Frameworks */,
- CD078D9A1DD4B5B30083F53F /* Headers */,
- CD078D9B1DD4B5B30083F53F /* Resources */,
- );
- buildRules = (
- );
- dependencies = (
- );
- name = ScrollableSegmentedControl;
- productName = ScrollableSegmentedControl;
- productReference = CD078D9D1DD4B5B30083F53F /* ScrollableSegmentedControl.framework */;
- productType = "com.apple.product-type.framework";
- };
- CD078DA51DD4B5B30083F53F /* ScrollableSegmentedControlTests */ = {
- isa = PBXNativeTarget;
- buildConfigurationList = CD078DB41DD4B5B30083F53F /* Build configuration list for PBXNativeTarget "ScrollableSegmentedControlTests" */;
- buildPhases = (
- CD078DA21DD4B5B30083F53F /* Sources */,
- CD078DA31DD4B5B30083F53F /* Frameworks */,
- CD078DA41DD4B5B30083F53F /* Resources */,
- );
- buildRules = (
- );
- dependencies = (
- CD078DA91DD4B5B30083F53F /* PBXTargetDependency */,
- );
- name = ScrollableSegmentedControlTests;
- productName = ScrollableSegmentedControlTests;
- productReference = CD078DA61DD4B5B30083F53F /* ScrollableSegmentedControlTests.xctest */;
- productType = "com.apple.product-type.bundle.unit-test";
- };
-/* End PBXNativeTarget section */
-
-/* Begin PBXProject section */
- CD078D941DD4B5B30083F53F /* Project object */ = {
- isa = PBXProject;
- attributes = {
- LastSwiftUpdateCheck = 0800;
- LastUpgradeCheck = 0940;
- ORGANIZATIONNAME = Pomarium;
- TargetAttributes = {
- CD078D9C1DD4B5B30083F53F = {
- CreatedOnToolsVersion = 8.0;
- LastSwiftMigration = 0900;
- ProvisioningStyle = Automatic;
- };
- CD078DA51DD4B5B30083F53F = {
- CreatedOnToolsVersion = 8.0;
- ProvisioningStyle = Automatic;
- };
- };
- };
- buildConfigurationList = CD078D971DD4B5B30083F53F /* Build configuration list for PBXProject "ScrollableSegmentedControl" */;
- compatibilityVersion = "Xcode 3.2";
- developmentRegion = English;
- hasScannedForEncodings = 0;
- knownRegions = (
- en,
- );
- mainGroup = CD078D931DD4B5B30083F53F;
- productRefGroup = CD078D9E1DD4B5B30083F53F /* Products */;
- projectDirPath = "";
- projectRoot = "";
- targets = (
- CD078D9C1DD4B5B30083F53F /* ScrollableSegmentedControl */,
- CD078DA51DD4B5B30083F53F /* ScrollableSegmentedControlTests */,
- );
- };
-/* End PBXProject section */
-
-/* Begin PBXResourcesBuildPhase section */
- CD078D9B1DD4B5B30083F53F /* Resources */ = {
- isa = PBXResourcesBuildPhase;
- buildActionMask = 2147483647;
- files = (
- );
- runOnlyForDeploymentPostprocessing = 0;
- };
- CD078DA41DD4B5B30083F53F /* Resources */ = {
- isa = PBXResourcesBuildPhase;
- buildActionMask = 2147483647;
- files = (
- );
- runOnlyForDeploymentPostprocessing = 0;
- };
-/* End PBXResourcesBuildPhase section */
-
-/* Begin PBXSourcesBuildPhase section */
- CD078D981DD4B5B30083F53F /* Sources */ = {
- isa = PBXSourcesBuildPhase;
- buildActionMask = 2147483647;
- files = (
- CD078DB81DD4B69F0083F53F /* ScrollableSegmentedControl.swift in Sources */,
- );
- runOnlyForDeploymentPostprocessing = 0;
- };
- CD078DA21DD4B5B30083F53F /* Sources */ = {
- isa = PBXSourcesBuildPhase;
- buildActionMask = 2147483647;
- files = (
- CD078DAC1DD4B5B30083F53F /* ScrollableSegmentedControlTests.swift in Sources */,
- );
- runOnlyForDeploymentPostprocessing = 0;
- };
-/* End PBXSourcesBuildPhase section */
-
-/* Begin PBXTargetDependency section */
- CD078DA91DD4B5B30083F53F /* PBXTargetDependency */ = {
- isa = PBXTargetDependency;
- target = CD078D9C1DD4B5B30083F53F /* ScrollableSegmentedControl */;
- targetProxy = CD078DA81DD4B5B30083F53F /* PBXContainerItemProxy */;
- };
-/* End PBXTargetDependency section */
-
-/* Begin XCBuildConfiguration section */
- CD078DAF1DD4B5B30083F53F /* Debug */ = {
- isa = XCBuildConfiguration;
- buildSettings = {
- ALWAYS_SEARCH_USER_PATHS = NO;
- CLANG_ANALYZER_NONNULL = YES;
- CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
- 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_SUSPICIOUS_MOVES = YES;
- CLANG_WARN_UNREACHABLE_CODE = YES;
- CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
- "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
- COPY_PHASE_STRIP = NO;
- CURRENT_PROJECT_VERSION = 1;
- DEBUG_INFORMATION_FORMAT = dwarf;
- ENABLE_STRICT_OBJC_MSGSEND = YES;
- ENABLE_TESTABILITY = YES;
- GCC_C_LANGUAGE_STANDARD = gnu99;
- GCC_DYNAMIC_NO_PIC = NO;
- GCC_NO_COMMON_BLOCKS = YES;
- GCC_OPTIMIZATION_LEVEL = 0;
- GCC_PREPROCESSOR_DEFINITIONS = (
- "DEBUG=1",
- "$(inherited)",
- );
- GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
- GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
- GCC_WARN_UNDECLARED_SELECTOR = YES;
- GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
- GCC_WARN_UNUSED_FUNCTION = YES;
- GCC_WARN_UNUSED_VARIABLE = YES;
- MTL_ENABLE_DEBUG_INFO = YES;
- ONLY_ACTIVE_ARCH = YES;
- SDKROOT = iphoneos;
- SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG;
- SWIFT_OPTIMIZATION_LEVEL = "-Onone";
- SWIFT_VERSION = 4.0;
- TARGETED_DEVICE_FAMILY = "1,2";
- VERSIONING_SYSTEM = "apple-generic";
- VERSION_INFO_PREFIX = "";
- };
- name = Debug;
- };
- CD078DB01DD4B5B30083F53F /* Release */ = {
- isa = XCBuildConfiguration;
- buildSettings = {
- ALWAYS_SEARCH_USER_PATHS = NO;
- CLANG_ANALYZER_NONNULL = YES;
- CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
- 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_SUSPICIOUS_MOVES = YES;
- CLANG_WARN_UNREACHABLE_CODE = YES;
- CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
- "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
- COPY_PHASE_STRIP = NO;
- CURRENT_PROJECT_VERSION = 1;
- DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
- ENABLE_NS_ASSERTIONS = NO;
- ENABLE_STRICT_OBJC_MSGSEND = YES;
- GCC_C_LANGUAGE_STANDARD = gnu99;
- GCC_NO_COMMON_BLOCKS = YES;
- GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
- GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
- GCC_WARN_UNDECLARED_SELECTOR = YES;
- GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
- GCC_WARN_UNUSED_FUNCTION = YES;
- GCC_WARN_UNUSED_VARIABLE = YES;
- MTL_ENABLE_DEBUG_INFO = NO;
- SDKROOT = iphoneos;
- SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
- SWIFT_VERSION = 4.0;
- TARGETED_DEVICE_FAMILY = "1,2";
- VALIDATE_PRODUCT = YES;
- VERSIONING_SYSTEM = "apple-generic";
- VERSION_INFO_PREFIX = "";
- };
- name = Release;
- };
- CD078DB21DD4B5B30083F53F /* Debug */ = {
- isa = XCBuildConfiguration;
- buildSettings = {
- CLANG_ENABLE_MODULES = YES;
- CODE_SIGN_IDENTITY = "";
- DEFINES_MODULE = YES;
- DYLIB_COMPATIBILITY_VERSION = 1;
- DYLIB_CURRENT_VERSION = 1;
- DYLIB_INSTALL_NAME_BASE = "@rpath";
- INFOPLIST_FILE = ScrollableSegmentedControl/Info.plist;
- INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
- IPHONEOS_DEPLOYMENT_TARGET = 9.0;
- LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
- PRODUCT_BUNDLE_IDENTIFIER = au.com.pomarium.ScrollableSegmentedControl;
- PRODUCT_NAME = "$(TARGET_NAME)";
- SKIP_INSTALL = YES;
- SWIFT_OPTIMIZATION_LEVEL = "-Onone";
- SWIFT_SWIFT3_OBJC_INFERENCE = Default;
- SWIFT_VERSION = 4.0;
- };
- name = Debug;
- };
- CD078DB31DD4B5B30083F53F /* Release */ = {
- isa = XCBuildConfiguration;
- buildSettings = {
- CLANG_ENABLE_MODULES = YES;
- CODE_SIGN_IDENTITY = "";
- DEFINES_MODULE = YES;
- DYLIB_COMPATIBILITY_VERSION = 1;
- DYLIB_CURRENT_VERSION = 1;
- DYLIB_INSTALL_NAME_BASE = "@rpath";
- INFOPLIST_FILE = ScrollableSegmentedControl/Info.plist;
- INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
- IPHONEOS_DEPLOYMENT_TARGET = 9.0;
- LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
- LLVM_LTO = YES;
- PRODUCT_BUNDLE_IDENTIFIER = au.com.pomarium.ScrollableSegmentedControl;
- PRODUCT_NAME = "$(TARGET_NAME)";
- SKIP_INSTALL = YES;
- SWIFT_SWIFT3_OBJC_INFERENCE = Default;
- SWIFT_VERSION = 4.0;
- };
- name = Release;
- };
- CD078DB51DD4B5B30083F53F /* Debug */ = {
- isa = XCBuildConfiguration;
- buildSettings = {
- ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
- INFOPLIST_FILE = ScrollableSegmentedControlTests/Info.plist;
- LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
- PRODUCT_BUNDLE_IDENTIFIER = au.com.pomarium.ScrollableSegmentedControlTests;
- PRODUCT_NAME = "$(TARGET_NAME)";
- SWIFT_VERSION = 4.0;
- };
- name = Debug;
- };
- CD078DB61DD4B5B30083F53F /* Release */ = {
- isa = XCBuildConfiguration;
- buildSettings = {
- ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
- INFOPLIST_FILE = ScrollableSegmentedControlTests/Info.plist;
- LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
- PRODUCT_BUNDLE_IDENTIFIER = au.com.pomarium.ScrollableSegmentedControlTests;
- PRODUCT_NAME = "$(TARGET_NAME)";
- SWIFT_VERSION = 4.0;
- };
- name = Release;
- };
-/* End XCBuildConfiguration section */
-
-/* Begin XCConfigurationList section */
- CD078D971DD4B5B30083F53F /* Build configuration list for PBXProject "ScrollableSegmentedControl" */ = {
- isa = XCConfigurationList;
- buildConfigurations = (
- CD078DAF1DD4B5B30083F53F /* Debug */,
- CD078DB01DD4B5B30083F53F /* Release */,
- );
- defaultConfigurationIsVisible = 0;
- defaultConfigurationName = Release;
- };
- CD078DB11DD4B5B30083F53F /* Build configuration list for PBXNativeTarget "ScrollableSegmentedControl" */ = {
- isa = XCConfigurationList;
- buildConfigurations = (
- CD078DB21DD4B5B30083F53F /* Debug */,
- CD078DB31DD4B5B30083F53F /* Release */,
- );
- defaultConfigurationIsVisible = 0;
- defaultConfigurationName = Release;
- };
- CD078DB41DD4B5B30083F53F /* Build configuration list for PBXNativeTarget "ScrollableSegmentedControlTests" */ = {
- isa = XCConfigurationList;
- buildConfigurations = (
- CD078DB51DD4B5B30083F53F /* Debug */,
- CD078DB61DD4B5B30083F53F /* Release */,
- );
- defaultConfigurationIsVisible = 0;
- defaultConfigurationName = Release;
- };
-/* End XCConfigurationList section */
- };
- rootObject = CD078D941DD4B5B30083F53F /* Project object */;
-}
diff --git a/ScrollableSegmentedControl.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/ScrollableSegmentedControl.xcodeproj/project.xcworkspace/contents.xcworkspacedata
deleted file mode 100644
index c48df21..0000000
--- a/ScrollableSegmentedControl.xcodeproj/project.xcworkspace/contents.xcworkspacedata
+++ /dev/null
@@ -1,7 +0,0 @@
-
-
-
-
-
diff --git a/ScrollableSegmentedControl/Info.plist b/ScrollableSegmentedControl/Info.plist
deleted file mode 100644
index 18065b5..0000000
--- a/ScrollableSegmentedControl/Info.plist
+++ /dev/null
@@ -1,24 +0,0 @@
-
-
-
-
- CFBundleDevelopmentRegion
- en
- CFBundleExecutable
- $(EXECUTABLE_NAME)
- CFBundleIdentifier
- $(PRODUCT_BUNDLE_IDENTIFIER)
- CFBundleInfoDictionaryVersion
- 6.0
- CFBundleName
- $(PRODUCT_NAME)
- CFBundlePackageType
- FMWK
- CFBundleShortVersionString
- 1.3.0
- CFBundleVersion
- $(CURRENT_PROJECT_VERSION)
- NSPrincipalClass
-
-
-
diff --git a/ScrollableSegmentedControl/ScrollableSegmentedControl.h b/ScrollableSegmentedControl/ScrollableSegmentedControl.h
deleted file mode 100644
index 31561ce..0000000
--- a/ScrollableSegmentedControl/ScrollableSegmentedControl.h
+++ /dev/null
@@ -1,19 +0,0 @@
-//
-// ScrollableSegmentedControl.h
-// ScrollableSegmentedControl
-//
-// Created by Goce Petrovski on 10/11/16.
-// Copyright © 2016 Pomarium. All rights reserved.
-//
-
-#import
-
-//! Project version number for ScrollableSegmentedControl.
-FOUNDATION_EXPORT double ScrollableSegmentedControlVersionNumber;
-
-//! Project version string for ScrollableSegmentedControl.
-FOUNDATION_EXPORT const unsigned char ScrollableSegmentedControlVersionString[];
-
-// In this header, you should import all the public headers of your framework using statements like #import
-
-
diff --git a/ScrollableSegmentedControlTests/Info.plist b/ScrollableSegmentedControlTests/Info.plist
deleted file mode 100644
index 6c6c23c..0000000
--- a/ScrollableSegmentedControlTests/Info.plist
+++ /dev/null
@@ -1,22 +0,0 @@
-
-
-
-
- CFBundleDevelopmentRegion
- en
- CFBundleExecutable
- $(EXECUTABLE_NAME)
- CFBundleIdentifier
- $(PRODUCT_BUNDLE_IDENTIFIER)
- CFBundleInfoDictionaryVersion
- 6.0
- CFBundleName
- $(PRODUCT_NAME)
- CFBundlePackageType
- BNDL
- CFBundleShortVersionString
- 1.0
- CFBundleVersion
- 1
-
-
diff --git a/ScrollableSegmentedControl/ScrollableSegmentedControl.swift b/Sources/ScrollableSegmentedControl/ScrollableSegmentedControl.swift
similarity index 84%
rename from ScrollableSegmentedControl/ScrollableSegmentedControl.swift
rename to Sources/ScrollableSegmentedControl/ScrollableSegmentedControl.swift
index b3a4211..e50c0a8 100644
--- a/ScrollableSegmentedControl/ScrollableSegmentedControl.swift
+++ b/Sources/ScrollableSegmentedControl/ScrollableSegmentedControl.swift
@@ -37,7 +37,20 @@ public enum ScrollableSegmentedControlSegmentStyle: Int {
}
}
}
-
+
+ /**
+ A Boolean value that determines if the width of the segment is going to fit the screen width.
+
+ When this value is set to true all segments have the same width which equivalent of the width required to display all the segments on screen.
+ The default value is false.
+ */
+ public var segmentWidthFitScreenSize: Bool = false {
+ didSet {
+ if oldValue != segmentWidthFitScreenSize {
+ setNeedsLayout()
+ }
+ }
+ }
@objc public var segmentStyle:ScrollableSegmentedControlSegmentStyle = .textOnly {
didSet {
@@ -74,7 +87,7 @@ public enum ScrollableSegmentedControlSegmentStyle: Int {
if indexPath != nil {
DispatchQueue.main.asyncAfter(deadline: .now() + 0.05, execute: {
- self.collectionView?.selectItem(at: indexPath, animated: true, scrollPosition: UICollectionViewScrollPosition.left)
+ self.collectionView?.selectItem(at: indexPath, animated: true, scrollPosition: UICollectionView.ScrollPosition.left)
})
}
}
@@ -106,7 +119,10 @@ public enum ScrollableSegmentedControlSegmentStyle: Int {
reloadSegments()
}
}
-
+
+ @objc public dynamic var badgeYRatio: CGFloat = 0
+ @objc public dynamic var badgeViewSize: CGFloat = 10
+ @objc public dynamic var badgeColor: UIColor = .red
override public init(frame: CGRect) {
super.init(frame: frame)
@@ -118,16 +134,16 @@ public enum ScrollableSegmentedControlSegmentStyle: Int {
configure()
}
- fileprivate var normalAttributes:[NSAttributedStringKey : Any]?
- fileprivate var highlightedAttributes:[NSAttributedStringKey : Any]?
- fileprivate var selectedAttributes:[NSAttributedStringKey : Any]?
- fileprivate var _titleAttributes:[UInt: [NSAttributedStringKey : Any]] = [UInt: [NSAttributedStringKey : Any]]()
- @objc public func setTitleTextAttributes(_ attributes: [NSAttributedStringKey : Any]?, for state: UIControlState) {
+ fileprivate var normalAttributes:[NSAttributedString.Key : Any]?
+ fileprivate var highlightedAttributes:[NSAttributedString.Key : Any]?
+ fileprivate var selectedAttributes:[NSAttributedString.Key : Any]?
+ fileprivate var _titleAttributes:[UInt: [NSAttributedString.Key : Any]] = [UInt: [NSAttributedString.Key : Any]]()
+ @objc public func setTitleTextAttributes(_ attributes: [NSAttributedString.Key : Any]?, for state: UIControl.State) {
_titleAttributes[state.rawValue] = attributes
- normalAttributes = _titleAttributes[UIControlState.normal.rawValue]
- highlightedAttributes = _titleAttributes[UIControlState.highlighted.rawValue]
- selectedAttributes = _titleAttributes[UIControlState.selected.rawValue]
+ normalAttributes = _titleAttributes[UIControl.State.normal.rawValue]
+ highlightedAttributes = _titleAttributes[UIControl.State.highlighted.rawValue]
+ selectedAttributes = _titleAttributes[UIControl.State.selected.rawValue]
for segment in segmentsData {
configureAttributedTitlesForSegment(segment)
@@ -177,7 +193,7 @@ public enum ScrollableSegmentedControlSegmentStyle: Int {
}
}
- @objc public func titleTextAttributes(for state: UIControlState) -> [NSAttributedStringKey : Any]? {
+ @objc public func titleTextAttributes(for state: UIControl.State) -> [NSAttributedString.Key : Any]? {
return _titleAttributes[state.rawValue]
}
@@ -209,18 +225,26 @@ public enum ScrollableSegmentedControlSegmentStyle: Int {
/**
Inserts a segment at a specific position in the receiver and gives it a title as content and/or image as content.
*/
- @objc public func insertSegment(withTitle title: String?, image: UIImage?, at index: Int) {
+ @objc public func insertSegment(withTitle title: String?, image: UIImage?, at index: Int, withBadge: Bool = false) {
let segment = SegmentData()
segment.title = title
segment.image = image?.withRenderingMode(.alwaysTemplate)
+ segment.badge = withBadge
segmentsData.insert(segment, at: index)
-
+
if let str = title {
calculateLongestTextWidth(text: str)
}
reloadSegments()
}
-
+
+ @objc public func updateSegmentBadge(at index: Int, withBadge: Bool = false) {
+ let segment = segmentsData[index]
+ segment.badge = withBadge
+
+ reloadSegments()
+ }
+
/**
Removes segment at a specific position from the receiver.
*/
@@ -267,19 +291,27 @@ public enum ScrollableSegmentedControlSegmentStyle: Int {
collectionView?.deselectItem(at: indexPath, animated: true)
}
}
-
+
if oldValue != selectedSegmentIndex {
+ collectionView?.layoutIfNeeded()
+ if let item = self.collectionView?.cellForItem(at: IndexPath(item: oldValue, section: 0)) as? ImageOnTopSegmentCollectionViewCell {
+ item.isHighlighted = false
+ }
self.sendActions(for: .valueChanged)
}
}
}
-
+
/**
Configure if the selected segment should have underline. Default value is false.
*/
@IBInspectable
@objc public var underlineSelected:Bool = false
+ @objc public var underlineUnselectedColor:UIColor = .clear
+ @objc public var underlineSelectedMargins: CGFloat = 0
+ @objc public var underlineUnselectedMargins: CGFloat = 0
+ @objc public var underlineHeight: CGFloat = 3
// MARK: - Layout management
override public func layoutSubviews() {
@@ -321,8 +353,13 @@ public enum ScrollableSegmentedControlSegmentStyle: Int {
fileprivate func configureSegmentSize() {
let width:CGFloat
-
- if fixedSegmentWidth == true {
+
+ if segmentWidthFitScreenSize {
+ width = UIScreen.main.bounds.width / CGFloat(segmentsData.count)
+
+ flowLayout.estimatedItemSize = CGSize()
+ flowLayout.itemSize = CGSize(width: width, height: frame.size.height)
+ } else if fixedSegmentWidth == true {
switch segmentStyle {
case .imageOnLeft:
width = longestTextWidth + BaseSegmentCollectionViewCell.imageSize + BaseSegmentCollectionViewCell.imageToTextMargin * 2
@@ -333,7 +370,7 @@ public enum ScrollableSegmentedControlSegmentStyle: Int {
width = longestTextWidth
}
}
-
+
flowLayout.estimatedItemSize = CGSize()
flowLayout.itemSize = CGSize(width: width, height: frame.size.height)
} else {
@@ -344,7 +381,7 @@ public enum ScrollableSegmentedControlSegmentStyle: Int {
}
fileprivate func calculateLongestTextWidth(text:String) {
- let fontAttributes:[NSAttributedStringKey:Any]
+ let fontAttributes:[NSAttributedString.Key:Any]
if normalAttributes != nil {
fontAttributes = normalAttributes!
} else if highlightedAttributes != nil {
@@ -352,7 +389,7 @@ public enum ScrollableSegmentedControlSegmentStyle: Int {
} else if selectedAttributes != nil {
fontAttributes = selectedAttributes!
} else {
- fontAttributes = [NSAttributedStringKey.font: BaseSegmentCollectionViewCell.defaultFont]
+ fontAttributes = [NSAttributedString.Key.font: BaseSegmentCollectionViewCell.defaultFont]
}
let size = (text as NSString).size(withAttributes: fontAttributes)
@@ -373,32 +410,37 @@ public enum ScrollableSegmentedControlSegmentStyle: Int {
} else {
segmentData = segmentsData[index]
}
-
+
return segmentData
}
-
+
fileprivate func reloadSegments() {
if let collectionView_ = collectionView {
collectionView_.reloadData()
if selectedSegmentIndex >= 0 {
let indexPath = IndexPath(item: selectedSegmentIndex, section: 0)
collectionView_.selectItem(at: indexPath, animated: true, scrollPosition: .left)
+ collectionView_.layoutIfNeeded()
+ if let item = self.collectionView?.cellForItem(at: indexPath) as? ImageOnTopSegmentCollectionViewCell {
+ item.isHighlighted = true
+ }
}
}
}
-
+
/*
Private internal classes to be used only by this class.
*/
-
+
// MARK: - SegmentData
-
+
final private class SegmentData {
var title:String?
var normalAttributedTitle:NSAttributedString?
var highlightedAttributedTitle:NSAttributedString?
var selectedAttributedTitle:NSAttributedString?
var image:UIImage?
+ var badge:Bool = false
}
// MARK : - CollectionViewController
@@ -446,7 +488,11 @@ public enum ScrollableSegmentedControlSegmentStyle: Int {
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: CollectionViewController.imageOnTopCellIdentifier, for: indexPath) as! ImageOnTopSegmentCollectionViewCell
cell.titleLabel.text = data.title
cell.imageView.image = data.image
-
+ cell.badgeView.isHidden = !data.badge
+ cell.badgeView.frame = CGRect(x: cell.frame.size.width / 2 + segmentedControl.badgeViewSize, y: cell.frame.size.height * segmentedControl.badgeYRatio - segmentedControl.badgeViewSize / 2, width: segmentedControl.badgeViewSize, height: segmentedControl.badgeViewSize)
+ cell.badgeView.layer.cornerRadius = segmentedControl.badgeViewSize / 2
+ cell.badgeView.backgroundColor = segmentedControl.badgeColor
+
segmentCell = cell
case .imageOnLeft:
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: CollectionViewController.imageOnLeftCellIdentifier, for: indexPath) as! ImageOnLeftSegmentCollectionViewCell
@@ -457,6 +503,10 @@ public enum ScrollableSegmentedControlSegmentStyle: Int {
}
segmentCell.showUnderline = segmentedControl.underlineSelected
+ segmentCell.underlineUnselectedColor = segmentedControl.underlineUnselectedColor
+ segmentCell.underlineSelectedMargins = segmentedControl.underlineSelectedMargins
+ segmentCell.underlineUnselectedMargins = segmentedControl.underlineUnselectedMargins
+ segmentCell.underlineHeight = segmentedControl.underlineHeight
if segmentedControl.underlineSelected {
segmentCell.tintColor = segmentedControl.tintColor
}
@@ -524,6 +574,26 @@ public enum ScrollableSegmentedControlSegmentStyle: Int {
var highlightedAttributedTitle:NSAttributedString?
var selectedAttributedTitle:NSAttributedString?
var variableConstraints = [NSLayoutConstraint]()
+ var underlineUnselectedColor: UIColor?
+ var underlineSelectedMargins: CGFloat = 0 {
+ didSet {
+ updateUnderlineConstraints()
+ }
+ }
+ var underlineUnselectedMargins: CGFloat = 0 {
+ didSet {
+ updateUnderlineConstraints()
+ }
+ }
+ var underlineHeight: CGFloat = 3 {
+ didSet {
+ updateUnderlineConstraints()
+ }
+ }
+
+ var heightConstraint: NSLayoutConstraint?
+ var leadingContraint: NSLayoutConstraint?
+ var trailingContraint: NSLayoutConstraint?
var showUnderline:Bool = false {
didSet {
@@ -533,8 +603,8 @@ public enum ScrollableSegmentedControlSegmentStyle: Int {
} else {
underlineView = UIView()
underlineView!.tag = 999
- underlineView!.backgroundColor = tintColor
- underlineView!.isHidden = !isSelected
+ underlineView!.backgroundColor = isSelected ? tintColor : underlineUnselectedColor
+ underlineView!.isHidden = false
contentView.insertSubview(underlineView!, at: contentView.subviews.count)
}
@@ -542,10 +612,10 @@ public enum ScrollableSegmentedControlSegmentStyle: Int {
}
}
}
-
+
override var tintColor: UIColor!{
didSet{
- underlineView?.backgroundColor = tintColor
+ underlineView?.backgroundColor = isSelected ? tintColor : underlineUnselectedColor
}
}
@@ -566,28 +636,34 @@ public enum ScrollableSegmentedControlSegmentStyle: Int {
private func configureConstraints() {
if let underline = underlineView {
underline.translatesAutoresizingMaskIntoConstraints = false
- underline.heightAnchor.constraint(equalToConstant: 3.0).isActive = true
- underline.leadingAnchor.constraint(equalTo: contentView.leadingAnchor).isActive = true
- underline.trailingAnchor.constraint(equalTo: contentView.trailingAnchor).isActive = true
+ heightConstraint = underline.heightAnchor.constraint(equalToConstant: 3)
+ heightConstraint?.isActive = true
+ leadingContraint = underline.leadingAnchor.constraint(equalTo: contentView.leadingAnchor)
+ leadingContraint?.isActive = true
+ trailingContraint = underline.trailingAnchor.constraint(equalTo: contentView.trailingAnchor)
+ trailingContraint?.isActive = true
underline.bottomAnchor.constraint(equalTo: contentView.bottomAnchor).isActive = true
+
+ updateUnderlineConstraints()
}
}
+
+ private func updateUnderlineConstraints() {
+ self.leadingContraint?.constant = self.isSelected ? self.underlineSelectedMargins : self.underlineUnselectedMargins
+ self.trailingContraint?.constant = self.isSelected ? -self.underlineSelectedMargins : -self.underlineUnselectedMargins
+ self.heightConstraint?.constant = self.underlineHeight
+ }
override func setNeedsUpdateConstraints() {
super.setNeedsUpdateConstraints()
NSLayoutConstraint.deactivate(variableConstraints)
variableConstraints.removeAll()
}
-
- override var isHighlighted: Bool {
- didSet {
- underlineView?.isHidden = !isHighlighted
- }
- }
-
+
override var isSelected: Bool {
didSet {
- underlineView?.isHidden = !isSelected
+ underlineView?.backgroundColor = isSelected ? tintColor : underlineUnselectedColor
+ updateUnderlineConstraints()
}
}
}
@@ -712,6 +788,7 @@ public enum ScrollableSegmentedControlSegmentStyle: Int {
private class BaseImageSegmentCollectionViewCell: BaseSegmentCollectionViewCell {
let titleLabel = UILabel()
let imageView = UIImageView()
+ let badgeView = UIView()
internal let stackView = UIStackView()
override var contentColor:UIColor? {
@@ -778,7 +855,9 @@ public enum ScrollableSegmentedControlSegmentStyle: Int {
stackView.addArrangedSubview(titleLabel)
stackView.translatesAutoresizingMaskIntoConstraints = false
+ badgeView.isHidden = true
contentView.addSubview(stackView)
+ contentView.addSubview(badgeView)
}
override func updateConstraints() {
diff --git a/ScrollableSegmentedControlTests/ScrollableSegmentedControlTests.swift b/Tests/ScrollableSegmentedControlTests/ScrollableSegmentedControlTests.swift
similarity index 100%
rename from ScrollableSegmentedControlTests/ScrollableSegmentedControlTests.swift
rename to Tests/ScrollableSegmentedControlTests/ScrollableSegmentedControlTests.swift