0

I'd like to add a segmented controller to a navigation bar, below the title.

At the moment, I've got a storyboard UITableViewController with a CoreData-sourced dynamic table, embedded in a UINavigationController. I'd like the UISegmentedController to differentiate the sorting of the table.

There seems to be obj-C solutions available stackoverflow.com/questions/29480433/ and stackoverflow.com/questions/18813563, but I'm looking for a Swift solution, that resembles the native apps. I've also tried putting the segmented controller into a table cell with little success (can't get the action recognised). I'd prefer not to abandon the table view controller.

Any suggestions?

Community
  • 1
  • 1
Shane
  • 397
  • 1
  • 4
  • 15

1 Answers1

0

I replaced the UITableViewController with a UIViewController and UITableView, then added the UISegmentedController to a UIToolBar positioned below the UINavigationBar.

I used removeShadow for the navbar, then clipsToBounds for the toolbar. I also added another View to simulate the bottom shadow on the toolbar (because I couldn't get the toolbar shadow/background position function to work).

Shane
  • 397
  • 1
  • 4
  • 15