diff --git a/Example/BetterSegmentedControl.xcodeproj/project.pbxproj b/Example/BetterSegmentedControl.xcodeproj/project.pbxproj index 4b67021..27d8bc9 100644 --- a/Example/BetterSegmentedControl.xcodeproj/project.pbxproj +++ b/Example/BetterSegmentedControl.xcodeproj/project.pbxproj @@ -46,7 +46,7 @@ 607FACEA1AFB9204008FA782 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 607FACEB1AFB9204008FA782 /* Tests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Tests.swift; sourceTree = ""; }; 61D9FAAAFFAE7994D65963C2 /* Pods_BetterSegmentedControl_Example.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_BetterSegmentedControl_Example.framework; sourceTree = BUILT_PRODUCTS_DIR; }; - 82FBC36B5CC2D9017CEACA5B /* BetterSegmentedControl.podspec */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text; name = BetterSegmentedControl.podspec; path = ../BetterSegmentedControl.podspec; sourceTree = ""; }; + 82FBC36B5CC2D9017CEACA5B /* BetterSegmentedControl.podspec */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text; name = BetterSegmentedControl.podspec; path = ../BetterSegmentedControl.podspec; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.ruby; }; BA399992832E9047B3FF6F8B /* Pods-BetterSegmentedControl_Tests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-BetterSegmentedControl_Tests.release.xcconfig"; path = "Pods/Target Support Files/Pods-BetterSegmentedControl_Tests/Pods-BetterSegmentedControl_Tests.release.xcconfig"; sourceTree = ""; }; E35EF8EE3A68B8AA955DE5DE /* Pods-BetterSegmentedControl_Example.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-BetterSegmentedControl_Example.debug.xcconfig"; path = "Pods/Target Support Files/Pods-BetterSegmentedControl_Example/Pods-BetterSegmentedControl_Example.debug.xcconfig"; sourceTree = ""; }; F6F6B8A01C1E078308A9EB93 /* Pods-BetterSegmentedControl_Tests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-BetterSegmentedControl_Tests.debug.xcconfig"; path = "Pods/Target Support Files/Pods-BetterSegmentedControl_Tests/Pods-BetterSegmentedControl_Tests.debug.xcconfig"; sourceTree = ""; }; @@ -219,6 +219,7 @@ TargetAttributes = { 607FACCF1AFB9204008FA782 = { CreatedOnToolsVersion = 6.3.1; + DevelopmentTeam = 2BLC39WP62; LastSwiftMigration = 1020; }; 607FACE41AFB9204008FA782 = { @@ -513,6 +514,7 @@ baseConfigurationReference = E35EF8EE3A68B8AA955DE5DE /* Pods-BetterSegmentedControl_Example.debug.xcconfig */; buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + DEVELOPMENT_TEAM = 2BLC39WP62; INFOPLIST_FILE = BetterSegmentedControl/Info.plist; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; MODULE_NAME = ExampleApp; @@ -526,6 +528,7 @@ baseConfigurationReference = 12CB0D1475C52C17775132BF /* Pods-BetterSegmentedControl_Example.release.xcconfig */; buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + DEVELOPMENT_TEAM = 2BLC39WP62; INFOPLIST_FILE = BetterSegmentedControl/Info.plist; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; MODULE_NAME = ExampleApp; diff --git a/Example/BetterSegmentedControl/ViewController.swift b/Example/BetterSegmentedControl/ViewController.swift index deb213d..8190923 100644 --- a/Example/BetterSegmentedControl/ViewController.swift +++ b/Example/BetterSegmentedControl/ViewController.swift @@ -83,6 +83,28 @@ class ViewController: UIViewController { height: 32.0), titles: ["First", "Second", "Third"]) view.addSubview(appleStyledControl) + + // Control 7: Added as a line button + let borderSegmentedControl = BetterSegmentedControl( + frame: CGRect(x: 0.0, y: 332.0, width: view.bounds.width , height: 50.0), + segments: LabelSegment.segments(withTitles: ["Artists", "Albums"], + normalFont: UIFont(name: "HelveticaNeue", size: 16.0)!, + normalTextColor: .gray, + selectedFont: UIFont(name: "HelveticaNeue", size: 16.0)!, + selectedTextColor: UIColor(red: 0.97, green: 0.00, blue: 0.24, alpha: 1.00)), + index: 1, + options: [.backgroundColor(UIColor.white), + .backgroundBorderColor(UIColor.green), + .backgroundBorderWidth(1.0), + .indicatorViewBackgroundColor(UIColor.white), + .indicatorViewBorderWidth(1.0), + .indicatorViewBorderColor(UIColor.red), + .indicatorViewInset(0.0), + .cornerRadius(0.0), + .animationSpringDamping(1.0), + .panningDisabled(true)]) + + view.addSubview(borderSegmentedControl) } // MARK: - Action handlers diff --git a/Example/Podfile.lock b/Example/Podfile.lock index 96962ea..ea2c304 100644 --- a/Example/Podfile.lock +++ b/Example/Podfile.lock @@ -39,4 +39,4 @@ SPEC CHECKSUMS: PODFILE CHECKSUM: a84635a977f3d0e6850e7888935f489adb8fd939 -COCOAPODS: 1.8.4 +COCOAPODS: 1.9.0.beta.2 diff --git a/Pod/Classes/BetterSegmentedControl.swift b/Pod/Classes/BetterSegmentedControl.swift index 1410565..5593c22 100644 --- a/Pod/Classes/BetterSegmentedControl.swift +++ b/Pod/Classes/BetterSegmentedControl.swift @@ -87,6 +87,10 @@ import UIKit panningDisabled = value case let .backgroundColor(value): backgroundColor = value + case let .backgroundBorderColor(value): + backgroundBorderColor = value + case let .backgroundBorderWidth(value): + backgroundBorderWidth = value case let .cornerRadius(value): cornerRadius = value case let .animationDuration(value): @@ -150,6 +154,30 @@ import UIKit indicatorView.layer.borderColor = newValue?.cgColor } } + + /// The background view's border color. + @IBInspectable public var backgroundBorderColor: UIColor? { + get { + guard let color = normalSegmentsView.layer.borderColor else { + return nil + } + return UIColor(cgColor: color) + } + set { + normalSegmentsView.layer.borderColor = newValue?.cgColor + } + } + + /// The background view's border width. + @IBInspectable public var backgroundBorderWidth: CGFloat { + get { + return normalSegmentsView.layer.borderWidth + } + set { + normalSegmentsView.layer.borderWidth = newValue + } + } + /// The duration of the animation of an index change. Defaults to `0.3`. @IBInspectable public var animationDuration: TimeInterval = 0.3 /// The spring damping ratio of the animation of an index change. Defaults to `0.75`. Set to `1.0` for a no bounce effect. diff --git a/Pod/Classes/Options.swift b/Pod/Classes/Options.swift index 8fbbf67..b509e49 100644 --- a/Pod/Classes/Options.swift +++ b/Pod/Classes/Options.swift @@ -26,5 +26,7 @@ public enum BetterSegmentedControlOption { /* Other */ case backgroundColor(UIColor) + case backgroundBorderColor(UIColor) + case backgroundBorderWidth(CGFloat) case cornerRadius(CGFloat) }