From 1daccf19495584b36904786b2d045cd275a4ab05 Mon Sep 17 00:00:00 2001 From: Jordan Rilassi Date: Fri, 24 Aug 2018 14:42:49 +0200 Subject: [PATCH 01/13] Set optional underline unselected color --- .../ScrollableSegmentedControl.swift | 21 ++++++++----------- 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/ScrollableSegmentedControl/ScrollableSegmentedControl.swift b/ScrollableSegmentedControl/ScrollableSegmentedControl.swift index b3a4211..c419c51 100644 --- a/ScrollableSegmentedControl/ScrollableSegmentedControl.swift +++ b/ScrollableSegmentedControl/ScrollableSegmentedControl.swift @@ -279,6 +279,7 @@ public enum ScrollableSegmentedControlSegmentStyle: Int { */ @IBInspectable @objc public var underlineSelected:Bool = false + @objc public var underlineUnselectedColor:UIColor = .clear // MARK: - Layout management @@ -457,6 +458,7 @@ public enum ScrollableSegmentedControlSegmentStyle: Int { } segmentCell.showUnderline = segmentedControl.underlineSelected + segmentCell.underlineUnselectedColor = segmentedControl.underlineUnselectedColor if segmentedControl.underlineSelected { segmentCell.tintColor = segmentedControl.tintColor } @@ -524,6 +526,7 @@ public enum ScrollableSegmentedControlSegmentStyle: Int { var highlightedAttributedTitle:NSAttributedString? var selectedAttributedTitle:NSAttributedString? var variableConstraints = [NSLayoutConstraint]() + var underlineUnselectedColor: UIColor? var showUnderline:Bool = false { didSet { @@ -533,8 +536,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 +545,10 @@ public enum ScrollableSegmentedControlSegmentStyle: Int { } } } - + override var tintColor: UIColor!{ didSet{ - underlineView?.backgroundColor = tintColor + underlineView?.backgroundColor = isSelected ? tintColor : underlineUnselectedColor } } @@ -578,16 +581,10 @@ public enum ScrollableSegmentedControlSegmentStyle: Int { 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 } } } From 70c3f45e00ec85650cbe0944882de472d9bc9ab0 Mon Sep 17 00:00:00 2001 From: Jordan Rilassi Date: Fri, 24 Aug 2018 15:20:15 +0200 Subject: [PATCH 02/13] Implement margins for unselected underline --- .../ScrollableSegmentedControl.swift | 24 +++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/ScrollableSegmentedControl/ScrollableSegmentedControl.swift b/ScrollableSegmentedControl/ScrollableSegmentedControl.swift index c419c51..9373dd6 100644 --- a/ScrollableSegmentedControl/ScrollableSegmentedControl.swift +++ b/ScrollableSegmentedControl/ScrollableSegmentedControl.swift @@ -280,6 +280,7 @@ public enum ScrollableSegmentedControlSegmentStyle: Int { @IBInspectable @objc public var underlineSelected:Bool = false @objc public var underlineUnselectedColor:UIColor = .clear + @objc public var underlineUnselectedMargins: CGFloat = 0 // MARK: - Layout management @@ -459,6 +460,7 @@ public enum ScrollableSegmentedControlSegmentStyle: Int { segmentCell.showUnderline = segmentedControl.underlineSelected segmentCell.underlineUnselectedColor = segmentedControl.underlineUnselectedColor + segmentCell.underlineUnselectedMargins = segmentedControl.underlineUnselectedMargins if segmentedControl.underlineSelected { segmentCell.tintColor = segmentedControl.tintColor } @@ -527,6 +529,14 @@ public enum ScrollableSegmentedControlSegmentStyle: Int { var selectedAttributedTitle:NSAttributedString? var variableConstraints = [NSLayoutConstraint]() var underlineUnselectedColor: UIColor? + var underlineUnselectedMargins: CGFloat = 0 { + didSet { + updateUnderlineConstraints() + } + } + + var leadingContraint: NSLayoutConstraint? + var trailingContraint: NSLayoutConstraint? var showUnderline:Bool = false { didSet { @@ -570,11 +580,20 @@ public enum ScrollableSegmentedControlSegmentStyle: Int { 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 + 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 ? 0 : self.underlineUnselectedMargins + self.trailingContraint?.constant = self.isSelected ? 0 : -self.underlineUnselectedMargins + } override func setNeedsUpdateConstraints() { super.setNeedsUpdateConstraints() @@ -585,6 +604,7 @@ public enum ScrollableSegmentedControlSegmentStyle: Int { override var isSelected: Bool { didSet { underlineView?.backgroundColor = isSelected ? tintColor : underlineUnselectedColor + updateUnderlineConstraints() } } } From 3facb11f97192a53b18c0e14b7e0478a88271369 Mon Sep 17 00:00:00 2001 From: Jordan Rilassi Date: Fri, 24 Aug 2018 16:17:24 +0200 Subject: [PATCH 03/13] Implement height for unselected line --- .../ScrollableSegmentedControl.swift | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/ScrollableSegmentedControl/ScrollableSegmentedControl.swift b/ScrollableSegmentedControl/ScrollableSegmentedControl.swift index 9373dd6..7437db9 100644 --- a/ScrollableSegmentedControl/ScrollableSegmentedControl.swift +++ b/ScrollableSegmentedControl/ScrollableSegmentedControl.swift @@ -282,6 +282,7 @@ public enum ScrollableSegmentedControlSegmentStyle: Int { @objc public var underlineUnselectedColor:UIColor = .clear @objc public var underlineUnselectedMargins: CGFloat = 0 + @objc public var underlineHeight: CGFloat = 3 // MARK: - Layout management override public func layoutSubviews() { @@ -534,7 +535,13 @@ public enum ScrollableSegmentedControlSegmentStyle: Int { updateUnderlineConstraints() } } + var underlineHeight: CGFloat = 3 { + didSet { + updateUnderlineConstraints() + } + } + var heightConstraint: NSLayoutConstraint? var leadingContraint: NSLayoutConstraint? var trailingContraint: NSLayoutConstraint? @@ -579,7 +586,8 @@ public enum ScrollableSegmentedControlSegmentStyle: Int { private func configureConstraints() { if let underline = underlineView { underline.translatesAutoresizingMaskIntoConstraints = false - underline.heightAnchor.constraint(equalToConstant: 3.0).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) @@ -593,6 +601,7 @@ public enum ScrollableSegmentedControlSegmentStyle: Int { private func updateUnderlineConstraints() { self.leadingContraint?.constant = self.isSelected ? 0 : self.underlineUnselectedMargins self.trailingContraint?.constant = self.isSelected ? 0 : -self.underlineUnselectedMargins + self.heightConstraint?.constant = self.underlineHeight } override func setNeedsUpdateConstraints() { From eb381ca19964001796139da217c07618bd268bbf Mon Sep 17 00:00:00 2001 From: Jordan Rilassi Date: Fri, 24 Aug 2018 16:17:24 +0200 Subject: [PATCH 04/13] Implement height for unselected line --- ScrollableSegmentedControl/ScrollableSegmentedControl.swift | 1 + 1 file changed, 1 insertion(+) diff --git a/ScrollableSegmentedControl/ScrollableSegmentedControl.swift b/ScrollableSegmentedControl/ScrollableSegmentedControl.swift index 7437db9..fefb28e 100644 --- a/ScrollableSegmentedControl/ScrollableSegmentedControl.swift +++ b/ScrollableSegmentedControl/ScrollableSegmentedControl.swift @@ -462,6 +462,7 @@ public enum ScrollableSegmentedControlSegmentStyle: Int { segmentCell.showUnderline = segmentedControl.underlineSelected segmentCell.underlineUnselectedColor = segmentedControl.underlineUnselectedColor segmentCell.underlineUnselectedMargins = segmentedControl.underlineUnselectedMargins + segmentCell.underlineHeight = segmentedControl.underlineHeight if segmentedControl.underlineSelected { segmentCell.tintColor = segmentedControl.tintColor } From 636386e40cea4aadfbd5deb33a6e9cce8554668a Mon Sep 17 00:00:00 2001 From: Jordan Rilassi Date: Fri, 24 Aug 2018 16:53:13 +0200 Subject: [PATCH 05/13] Implement segmentedControl fits screen size --- .../ScrollableSegmentedControl.swift | 26 ++++++++++++++++--- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/ScrollableSegmentedControl/ScrollableSegmentedControl.swift b/ScrollableSegmentedControl/ScrollableSegmentedControl.swift index fefb28e..cfd3a00 100644 --- a/ScrollableSegmentedControl/ScrollableSegmentedControl.swift +++ b/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 { @@ -324,8 +337,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 @@ -336,7 +354,7 @@ public enum ScrollableSegmentedControlSegmentStyle: Int { width = longestTextWidth } } - + flowLayout.estimatedItemSize = CGSize() flowLayout.itemSize = CGSize(width: width, height: frame.size.height) } else { From ae1c32d49e78095233fe469ef9e4fc33204024c9 Mon Sep 17 00:00:00 2001 From: Jordan Rilassi Date: Fri, 24 Aug 2018 17:07:02 +0200 Subject: [PATCH 06/13] Implement underline selected margins --- .../ScrollableSegmentedControl.swift | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/ScrollableSegmentedControl/ScrollableSegmentedControl.swift b/ScrollableSegmentedControl/ScrollableSegmentedControl.swift index cfd3a00..d522c43 100644 --- a/ScrollableSegmentedControl/ScrollableSegmentedControl.swift +++ b/ScrollableSegmentedControl/ScrollableSegmentedControl.swift @@ -293,6 +293,7 @@ public enum ScrollableSegmentedControlSegmentStyle: Int { @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 @@ -479,6 +480,7 @@ public enum ScrollableSegmentedControlSegmentStyle: Int { segmentCell.showUnderline = segmentedControl.underlineSelected segmentCell.underlineUnselectedColor = segmentedControl.underlineUnselectedColor + segmentCell.underlineSelectedMarings = segmentedControl.underlineSelectedMargins segmentCell.underlineUnselectedMargins = segmentedControl.underlineUnselectedMargins segmentCell.underlineHeight = segmentedControl.underlineHeight if segmentedControl.underlineSelected { @@ -549,6 +551,11 @@ public enum ScrollableSegmentedControlSegmentStyle: Int { var selectedAttributedTitle:NSAttributedString? var variableConstraints = [NSLayoutConstraint]() var underlineUnselectedColor: UIColor? + var underlineSelectedMarings: CGFloat = 0 { + didSet { + updateUnderlineConstraints() + } + } var underlineUnselectedMargins: CGFloat = 0 { didSet { updateUnderlineConstraints() @@ -618,8 +625,8 @@ public enum ScrollableSegmentedControlSegmentStyle: Int { } private func updateUnderlineConstraints() { - self.leadingContraint?.constant = self.isSelected ? 0 : self.underlineUnselectedMargins - self.trailingContraint?.constant = self.isSelected ? 0 : -self.underlineUnselectedMargins + self.leadingContraint?.constant = self.isSelected ? self.underlineSelectedMarings : self.underlineUnselectedMargins + self.trailingContraint?.constant = self.isSelected ? -self.underlineSelectedMarings : -self.underlineUnselectedMargins self.heightConstraint?.constant = self.underlineHeight } From a0ccb7ce7161d1a16e1197ec861d85af5588b2e1 Mon Sep 17 00:00:00 2001 From: Jordan Rilassi Date: Fri, 24 Aug 2018 17:07:02 +0200 Subject: [PATCH 07/13] Implement underline selected margins --- .../ScrollableSegmentedControl.swift | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/ScrollableSegmentedControl/ScrollableSegmentedControl.swift b/ScrollableSegmentedControl/ScrollableSegmentedControl.swift index d522c43..9707869 100644 --- a/ScrollableSegmentedControl/ScrollableSegmentedControl.swift +++ b/ScrollableSegmentedControl/ScrollableSegmentedControl.swift @@ -480,7 +480,7 @@ public enum ScrollableSegmentedControlSegmentStyle: Int { segmentCell.showUnderline = segmentedControl.underlineSelected segmentCell.underlineUnselectedColor = segmentedControl.underlineUnselectedColor - segmentCell.underlineSelectedMarings = segmentedControl.underlineSelectedMargins + segmentCell.underlineSelectedMargins = segmentedControl.underlineSelectedMargins segmentCell.underlineUnselectedMargins = segmentedControl.underlineUnselectedMargins segmentCell.underlineHeight = segmentedControl.underlineHeight if segmentedControl.underlineSelected { @@ -551,7 +551,7 @@ public enum ScrollableSegmentedControlSegmentStyle: Int { var selectedAttributedTitle:NSAttributedString? var variableConstraints = [NSLayoutConstraint]() var underlineUnselectedColor: UIColor? - var underlineSelectedMarings: CGFloat = 0 { + var underlineSelectedMargins: CGFloat = 0 { didSet { updateUnderlineConstraints() } @@ -625,8 +625,8 @@ public enum ScrollableSegmentedControlSegmentStyle: Int { } private func updateUnderlineConstraints() { - self.leadingContraint?.constant = self.isSelected ? self.underlineSelectedMarings : self.underlineUnselectedMargins - self.trailingContraint?.constant = self.isSelected ? -self.underlineSelectedMarings : -self.underlineUnselectedMargins + self.leadingContraint?.constant = self.isSelected ? self.underlineSelectedMargins : self.underlineUnselectedMargins + self.trailingContraint?.constant = self.isSelected ? -self.underlineSelectedMargins : -self.underlineUnselectedMargins self.heightConstraint?.constant = self.underlineHeight } From e7aef89eb75bb4cdabe88d24657f8444b8475539 Mon Sep 17 00:00:00 2001 From: Jordan Rilassi Date: Thu, 29 Nov 2018 10:39:38 +0100 Subject: [PATCH 08/13] Support for Swift 4.2 --- .../xcshareddata/IDEWorkspaceChecks.plist | 8 +++++++ .../project.pbxproj | 9 +++---- .../xcshareddata/IDEWorkspaceChecks.plist | 8 +++++++ .../ScrollableSegmentedControl.swift | 24 +++++++++---------- 4 files changed, 33 insertions(+), 16 deletions(-) create mode 100644 Demo/ScrollableSegmentedControlDemo/ScrollableSegmentedControlDemo.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist create mode 100644 ScrollableSegmentedControl.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist 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/ScrollableSegmentedControl.xcodeproj/project.pbxproj b/ScrollableSegmentedControl.xcodeproj/project.pbxproj index cdcfda8..766a6e1 100644 --- a/ScrollableSegmentedControl.xcodeproj/project.pbxproj +++ b/ScrollableSegmentedControl.xcodeproj/project.pbxproj @@ -156,6 +156,7 @@ }; CD078DA51DD4B5B30083F53F = { CreatedOnToolsVersion = 8.0; + LastSwiftMigration = 1010; ProvisioningStyle = Automatic; }; }; @@ -358,7 +359,7 @@ SKIP_INSTALL = YES; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; SWIFT_SWIFT3_OBJC_INFERENCE = Default; - SWIFT_VERSION = 4.0; + SWIFT_VERSION = 4.2; }; name = Debug; }; @@ -380,7 +381,7 @@ PRODUCT_NAME = "$(TARGET_NAME)"; SKIP_INSTALL = YES; SWIFT_SWIFT3_OBJC_INFERENCE = Default; - SWIFT_VERSION = 4.0; + SWIFT_VERSION = 4.2; }; name = Release; }; @@ -392,7 +393,7 @@ 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; + SWIFT_VERSION = 4.2; }; name = Debug; }; @@ -404,7 +405,7 @@ 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; + SWIFT_VERSION = 4.2; }; name = Release; }; diff --git a/ScrollableSegmentedControl.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/ScrollableSegmentedControl.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist new file mode 100644 index 0000000..18d9810 --- /dev/null +++ b/ScrollableSegmentedControl.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist @@ -0,0 +1,8 @@ + + + + + IDEDidComputeMac32BitWarning + + + diff --git a/ScrollableSegmentedControl/ScrollableSegmentedControl.swift b/ScrollableSegmentedControl/ScrollableSegmentedControl.swift index 9707869..6394343 100644 --- a/ScrollableSegmentedControl/ScrollableSegmentedControl.swift +++ b/ScrollableSegmentedControl/ScrollableSegmentedControl.swift @@ -87,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) }) } } @@ -131,16 +131,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) @@ -190,7 +190,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] } @@ -366,7 +366,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 { @@ -374,7 +374,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) From dcb9f53fcede3ed600dca64c4cab8bc309e10b3a Mon Sep 17 00:00:00 2001 From: Jordan Rilassi Date: Thu, 29 Nov 2018 10:43:27 +0100 Subject: [PATCH 09/13] Podspec to v1.3.1 --- ScrollableSegmentedControl/Info.plist | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ScrollableSegmentedControl/Info.plist b/ScrollableSegmentedControl/Info.plist index 18065b5..9f9016a 100644 --- a/ScrollableSegmentedControl/Info.plist +++ b/ScrollableSegmentedControl/Info.plist @@ -15,7 +15,7 @@ CFBundlePackageType FMWK CFBundleShortVersionString - 1.3.0 + 1.3.1 CFBundleVersion $(CURRENT_PROJECT_VERSION) NSPrincipalClass From f34e52906dca8b893e5c1701e272266d4b14bfec Mon Sep 17 00:00:00 2001 From: Jordan Rilassi Date: Fri, 14 Dec 2018 16:41:35 +0100 Subject: [PATCH 10/13] Add badge displayable for mode .imageOnTop --- .../ScrollableSegmentedControl.swift | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/ScrollableSegmentedControl/ScrollableSegmentedControl.swift b/ScrollableSegmentedControl/ScrollableSegmentedControl.swift index 6394343..da331b4 100644 --- a/ScrollableSegmentedControl/ScrollableSegmentedControl.swift +++ b/ScrollableSegmentedControl/ScrollableSegmentedControl.swift @@ -222,12 +222,13 @@ 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) } @@ -421,6 +422,7 @@ public enum ScrollableSegmentedControlSegmentStyle: Int { var highlightedAttributedTitle:NSAttributedString? var selectedAttributedTitle:NSAttributedString? var image:UIImage? + var badge:Bool = false } // MARK : - CollectionViewController @@ -468,6 +470,7 @@ 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 segmentCell = cell case .imageOnLeft: @@ -764,6 +767,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? { @@ -830,7 +834,14 @@ public enum ScrollableSegmentedControlSegmentStyle: Int { stackView.addArrangedSubview(titleLabel) stackView.translatesAutoresizingMaskIntoConstraints = false + + badgeView.backgroundColor = .red + let badgeViewSize = CGFloat(10) + badgeView.frame = CGRect(x: contentView.frame.size.width / 2 + badgeViewSize, y: 0, width: badgeViewSize, height: badgeViewSize) + badgeView.layer.cornerRadius = badgeViewSize / 2 + badgeView.isHidden = true contentView.addSubview(stackView) + contentView.addSubview(badgeView) } override func updateConstraints() { From c27688d81589d0f20515674502c8f425b7e8c23b Mon Sep 17 00:00:00 2001 From: Jordan Rilassi Date: Fri, 14 Dec 2018 16:58:11 +0100 Subject: [PATCH 11/13] Add customization for badge --- .../ScrollableSegmentedControl.swift | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/ScrollableSegmentedControl/ScrollableSegmentedControl.swift b/ScrollableSegmentedControl/ScrollableSegmentedControl.swift index da331b4..109f1d5 100644 --- a/ScrollableSegmentedControl/ScrollableSegmentedControl.swift +++ b/ScrollableSegmentedControl/ScrollableSegmentedControl.swift @@ -119,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) @@ -471,7 +474,10 @@ public enum ScrollableSegmentedControlSegmentStyle: Int { 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 @@ -834,11 +840,6 @@ public enum ScrollableSegmentedControlSegmentStyle: Int { stackView.addArrangedSubview(titleLabel) stackView.translatesAutoresizingMaskIntoConstraints = false - - badgeView.backgroundColor = .red - let badgeViewSize = CGFloat(10) - badgeView.frame = CGRect(x: contentView.frame.size.width / 2 + badgeViewSize, y: 0, width: badgeViewSize, height: badgeViewSize) - badgeView.layer.cornerRadius = badgeViewSize / 2 badgeView.isHidden = true contentView.addSubview(stackView) contentView.addSubview(badgeView) From 36174ca33b800a7df743150d23c5028a68417257 Mon Sep 17 00:00:00 2001 From: Jordan Rilassi Date: Mon, 17 Dec 2018 14:13:48 +0100 Subject: [PATCH 12/13] Implement possibility to updateSegmentBadge at index --- .../ScrollableSegmentedControl.swift | 31 ++++++++++++++----- 1 file changed, 23 insertions(+), 8 deletions(-) diff --git a/ScrollableSegmentedControl/ScrollableSegmentedControl.swift b/ScrollableSegmentedControl/ScrollableSegmentedControl.swift index 109f1d5..e50c0a8 100644 --- a/ScrollableSegmentedControl/ScrollableSegmentedControl.swift +++ b/ScrollableSegmentedControl/ScrollableSegmentedControl.swift @@ -237,7 +237,14 @@ public enum ScrollableSegmentedControlSegmentStyle: Int { } 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. */ @@ -284,13 +291,17 @@ 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. */ @@ -399,26 +410,30 @@ 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? From 1af50cb2c9c899b6416a7ed2db965f832762a000 Mon Sep 17 00:00:00 2001 From: matthieu Date: Tue, 15 Feb 2022 09:50:20 +0100 Subject: [PATCH 13/13] supporting SPM --- .gitignore | 1 + .swift-version | 1 - Package.swift | 24 + ScrollableSegmentedControl.podspec | 14 - .../project.pbxproj | 445 ------------------ .../contents.xcworkspacedata | 7 - .../xcshareddata/IDEWorkspaceChecks.plist | 8 - ScrollableSegmentedControl/Info.plist | 24 - .../ScrollableSegmentedControl.h | 19 - ScrollableSegmentedControlTests/Info.plist | 22 - .../ScrollableSegmentedControl.swift | 0 .../ScrollableSegmentedControlTests.swift | 0 12 files changed, 25 insertions(+), 540 deletions(-) delete mode 100644 .swift-version create mode 100644 Package.swift delete mode 100644 ScrollableSegmentedControl.podspec delete mode 100644 ScrollableSegmentedControl.xcodeproj/project.pbxproj delete mode 100644 ScrollableSegmentedControl.xcodeproj/project.xcworkspace/contents.xcworkspacedata delete mode 100644 ScrollableSegmentedControl.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist delete mode 100644 ScrollableSegmentedControl/Info.plist delete mode 100644 ScrollableSegmentedControl/ScrollableSegmentedControl.h delete mode 100644 ScrollableSegmentedControlTests/Info.plist rename {ScrollableSegmentedControl => Sources/ScrollableSegmentedControl}/ScrollableSegmentedControl.swift (100%) rename {ScrollableSegmentedControlTests => Tests/ScrollableSegmentedControlTests}/ScrollableSegmentedControlTests.swift (100%) 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/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 766a6e1..0000000 --- a/ScrollableSegmentedControl.xcodeproj/project.pbxproj +++ /dev/null @@ -1,445 +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; - LastSwiftMigration = 1010; - 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.2; - }; - 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.2; - }; - 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.2; - }; - 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.2; - }; - 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.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/ScrollableSegmentedControl.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist deleted file mode 100644 index 18d9810..0000000 --- a/ScrollableSegmentedControl.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +++ /dev/null @@ -1,8 +0,0 @@ - - - - - IDEDidComputeMac32BitWarning - - - diff --git a/ScrollableSegmentedControl/Info.plist b/ScrollableSegmentedControl/Info.plist deleted file mode 100644 index 9f9016a..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.1 - 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 100% rename from ScrollableSegmentedControl/ScrollableSegmentedControl.swift rename to Sources/ScrollableSegmentedControl/ScrollableSegmentedControl.swift 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