DEV Community

Khoa Pham
Khoa Pham

Posted on

3 1

Introducing Dropdowns - Add dropdown to iOS app easily

I'm making a new framework, Dropdowns

Dropdowns provides the quickest way to present a dropdown in your app. It is very lightweight, just provide a list of items and the action closure you want to handle.

Dropdowns works by showing a child UIViewController as a dropdown from a TitleView. The most common use case is to show from a UINavigationController, in that sense, you can just create a list of items, and provide to TitleView.

let items = ["World", "Sports", "Culture", "Business", "Travel"]
let titleView = TitleView(navigationController: navigationController!, title: "Menu", items: items)
titleView?.action = { [weak self] index in
  print("select \(index)")
}

navigationItem.titleView = titleView

For customizations, Dropdowns uses TableController by default, to show list of items in a UITableView. We can customise to show anything you want by using contentController.

let contentController = TableController(items: items, initialIndex: 0)
let dropdown = DropdownController(contentController: contentController, navigationController: navigationController)

Sentry growth stunted Image

If you are wasting time trying to track down the cause of a crash, it’s time for a better solution. Get your crash rates to zero (or close to zero as possible) with less time and effort.

Try Sentry for more visibility into crashes, better workflow tools, and customizable alerts and reporting.

Switch Tools πŸ”

Top comments (0)

Sentry mobile image

Improving mobile performance, from slow screens to app start time

Based on our experience working with thousands of mobile developer teams, we developed a mobile monitoring maturity curve.

Read more

πŸ‘‹ Kindness is contagious

Please leave a ❀️ or a friendly comment on this post if you found it helpful!

Okay