0

enter image description here

Is this any Default Property in updated iOS14 or is it made in SwiftUI or is it a custom UIView?

  • If it is Default Property, then how to use it ? (is it available in Apple Documentation)
  • If it is in SwiftUI , How to use this property in Swift5 ?
  • If it is a Custom UIView, then How can I create one with opening and closing animation effects (if you have iPhone running iOS 14+, then you can see the animation effects when it opens or closes , it's like a Scaling Animation I guess) ???

Thanks

Nayan Dave
  • 1,078
  • 1
  • 8
  • 30

2 Answers2

2

There is a new feature in iOS14 (UIKit and swiftUI) called pulldown menu or context menu. Menu can now added to UIButtons and UIBarbuttonItems.

let tbMenu = UIMenu(title: "", children: /* UIActions */)
UIBarButtonItem(image: UIImage(systemName: "list.number"), menu: buttonMenu)

Pull-down menus Context menus (for TableViews)

Stefan Wieland
  • 246
  • 2
  • 4
1

There is a very good cocoa pod for this Dropdown

Its working is also very simple

creating dropdown

let dropDown = DropDown()
// The view to which the drop down will appear on
    dropDown.anchorView = view // UIView or UIBarButtonItem
// The list of items to display. Can be changed dynamically
    dropDown.dataSource = ["Car", "Motorcycle", "Truck"]

Optional Action properties

// Action triggered on selection
dropDown.selectionAction = { [unowned self] (index: Int, item: String) in
  print("Selected item: \(item) at index: \(index)")
}

// Will set a custom width instead of the anchor view width
dropDownLeft.width = 200

Display Actions are

dropDown.show()
dropDown.hide()

You can also do very advance things like customise cell , display direction etc have a look at the Documentation

Abdul Saboor
  • 102
  • 5
  • Yes @Abdul, I have also used `DropDown` but I wanted to know about the default feature which is in ios14+ devices.... Thanks for your contribution :) – Nayan Dave Oct 14 '20 at 12:34
  • @NayanDave this might help you https://medium.com/better-programming/using-ios-14s-menu-as-a-picker-in-swiftui-b036c772037 – Abdul Saboor Oct 22 '20 at 12:18