Commit fa22b193 authored by Tobias Due Munk's avatar Tobias Due Munk

Fix concatenated items in effect segmented control

parent 4dadde2a
......@@ -80,7 +80,7 @@ class EditorViewController: UIViewController {
outerStackView.leadingAnchor.constraint(equalTo: view.safeAreaLayoutGuide.leadingAnchor),
outerStackView.trailingAnchor.constraint(equalTo: view.safeAreaLayoutGuide.trailingAnchor),
outerStackView.bottomAnchor.constraint(equalTo: view.layoutMarginsGuide.bottomAnchor),
])
])
outerStackView.addArrangedSubview(inputsStackView)
......@@ -91,7 +91,7 @@ class EditorViewController: UIViewController {
outerStackView.addArrangedSubview(resultImageView)
resultImageView.setContentCompressionResistancePriority(.fittingSizeLevel, for: .vertical)
let segment = UISegmentedControl(items: effects.enumerated().map {
let segment = NoSwipeSegmentedControl(items: effects.enumerated().map {
let title = "\($0.offset + 1)" as NSString
title.accessibilityLabel = "Task"
return title
......@@ -102,7 +102,22 @@ class EditorViewController: UIViewController {
selectedEffect = min(selectedEffect, segment.numberOfSegments - 1)
segment.selectedSegmentIndex = selectedEffect
segment.addTarget(self, action: #selector(didChangeSegment), for: .valueChanged)
toolbarItems = [UIBarButtonItem(customView: segment)]
if #available(iOS 13.0, *) {
segment.selectedSegmentTintColor = UIColor(displayP3Red: 1, green: 0, blue: 0.1, alpha: 1)
}
let segmentsScroll = UIScrollView()
segmentsScroll.showsHorizontalScrollIndicator = false
segmentsScroll.addSubview(segment)
segment.translatesAutoresizingMaskIntoConstraints = false
NSLayoutConstraint.activate([
segment.leadingAnchor.constraint(equalTo: segmentsScroll.contentLayoutGuide.leadingAnchor),
segment.trailingAnchor.constraint(equalTo: segmentsScroll.contentLayoutGuide.trailingAnchor),
segment.topAnchor.constraint(equalTo: segmentsScroll.contentLayoutGuide.topAnchor),
segment.bottomAnchor.constraint(equalTo: segmentsScroll.contentLayoutGuide.bottomAnchor),
segment.heightAnchor.constraint(equalTo: segmentsScroll.heightAnchor),
])
toolbarItems = [UIBarButtonItem(customView: segmentsScroll)]
let toolbar = UIToolbar()
view.addSubview(toolbar)
......@@ -229,3 +244,10 @@ class InputImageView: UIView {
imageView.accessibilityLabel = title
}
}
private class NoSwipeSegmentedControl: UISegmentedControl {
override func gestureRecognizerShouldBegin(_ gestureRecognizer: UIGestureRecognizer) -> Bool {
return true
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment