Вот мой код реализации:
@IBOutlet var toolBar: UIToolbar!
@IBOutlet var segmentControl: UISegmentedControl!
override func viewDidLoad() {
super.viewDidLoad()
self.title = "Media"
self.toolBar.delegate = self
setupSegmentControl()
}
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
navigationController?.navigationBar.setBackgroundImage(UIImage(), for: .default)
navigationController?.navigationBar.shadowImage = UIImage()
}
override func viewWillDisappear(_ animated: Bool) {
super.viewWillDisappear(animated)
navigationController?.navigationBar.setBackgroundImage(nil, for: .default)
navigationController?.navigationBar.shadowImage = nil
}
fileprivate func setupSegmentControl() {
let items = ["Photo", "Video", "Document"]
self.segmentControl.removeAllSegments()
for item in items {
self.segmentControl.insertSegment(withTitle: item, at: items.index(of: item)!, animated: false)
}
self.segmentControl.selectedSegmentIndex = 0
}
func position(for bar: UIBarPositioning) -> UIBarPosition {
return UIBarPosition.topAttached
}
У меня были странные вещи, а затем переход к контроллеру: я пытался установить цвет оттенка или изменить размер, но это не помогло.Где суть дела?![enter image description here](https://i.stack.imgur.com/QF7a5.png)