diff --git a/DropdownMenu.gif b/DropdownMenu.gif index fdd204a..2482923 100644 Binary files a/DropdownMenu.gif and b/DropdownMenu.gif differ diff --git a/DropdownMenuDemo/DropdownMenuDemo.xcodeproj/project.pbxproj b/DropdownMenuDemo/DropdownMenuDemo.xcodeproj/project.pbxproj index c52a75f..78505f0 100644 --- a/DropdownMenuDemo/DropdownMenuDemo.xcodeproj/project.pbxproj +++ b/DropdownMenuDemo/DropdownMenuDemo.xcodeproj/project.pbxproj @@ -223,7 +223,7 @@ TargetAttributes = { ACE6DB8E1CF741F6005C6667 = { CreatedOnToolsVersion = 7.3.1; - DevelopmentTeam = 7NLBE99QC4; + DevelopmentTeam = ZDUX4TJC7F; LastSwiftMigration = 0800; }; ACE6DBA21CF741F6005C6667 = { @@ -442,11 +442,11 @@ isa = XCBuildConfiguration; buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; - DEVELOPMENT_TEAM = 7NLBE99QC4; + DEVELOPMENT_TEAM = ZDUX4TJC7F; INFOPLIST_FILE = DropdownMenuDemo/Info.plist; IPHONEOS_DEPLOYMENT_TARGET = 8.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; - PRODUCT_BUNDLE_IDENTIFIER = com.teambition.DropdownMenuDemo; + PRODUCT_BUNDLE_IDENTIFIER = com.teambition.DropdownMenu2; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_VERSION = 3.0; }; @@ -456,11 +456,11 @@ isa = XCBuildConfiguration; buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; - DEVELOPMENT_TEAM = 7NLBE99QC4; + DEVELOPMENT_TEAM = ZDUX4TJC7F; INFOPLIST_FILE = DropdownMenuDemo/Info.plist; IPHONEOS_DEPLOYMENT_TARGET = 8.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; - PRODUCT_BUNDLE_IDENTIFIER = com.teambition.DropdownMenuDemo; + PRODUCT_BUNDLE_IDENTIFIER = com.teambition.DropdownMenu2; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_VERSION = 3.0; }; diff --git a/README.md b/README.md index c86f3fd..da2cb79 100644 --- a/README.md +++ b/README.md @@ -7,6 +7,11 @@ ![](./DropdownMenu.gif) ## Features + +- Dropdown Menu +- Dropup Menu + +### Surpport cell type - **Only text cell** - **Image and text cell** - **Highlight cell** @@ -26,6 +31,33 @@ > **Embedded frameworks require a minimum deployment target of iOS 8 +### CocoaPods + +[CocoaPods](http://cocoapods.org) is a dependency manager for Cocoa projects. You can install it with the following command: + +```bash +$ gem install cocoapods +``` + +To integrate Alamofire into your Xcode project using CocoaPods, specify it in your `Podfile`: + +```ruby +source 'https://github.com/CocoaPods/Specs.git' +platform :ios, '8.0' +use_frameworks! + +target '' do + pod 'DropdownMenu' +end +``` + +Then, run the following command: + +```bash +$ pod install +``` + + ### Carthage [Carthage](https://github.com/Carthage/Carthage) is a decentralized dependency manager that builds your dependencies and provides you with binary frameworks. @@ -60,16 +92,18 @@ For more information about how to use Carthage, please see its [project page](ht ## Usage -### Import framework to your class +#### Import framework to your class ```swift import DropdownMenu ``` -### Add code for your action +### DropdownMenu + +#### Add code for your action -#### Without Section +##### Without Section ```swift func showMenu(sender: UIBarButtonItem) { @@ -85,7 +119,7 @@ func showMenu(sender: UIBarButtonItem) { } ``` -#### With Section +##### With Section ```swift @IBAction func showMenu(_ sender: UIBarButtonItem) { @@ -103,7 +137,7 @@ func showMenu(sender: UIBarButtonItem) { } ``` -### Handle delegate +#### Handle delegate ```swift extension ViewController: DropdownMenuDelegate { @@ -113,6 +147,45 @@ extension ViewController: DropdownMenuDelegate { } ``` +### DropupMenu + +#### Add code for your action + +```swift +@IBAction func dropUpAction(_ sender: UIBarButtonItem) { + let item1 = DropdownItem(title: "NO Image") + let item2 = DropdownItem(image: UIImage(named: "file")!, title: "File") + let item3 = DropdownItem(image: UIImage(named: "post")!, title: "Post", style: .highlight) + let item4 = DropdownItem(image: UIImage(named: "post")!, title: "Event", style: .highlight, accessoryImage: UIImage(named: "accessory")!) + + let data = [item1, item2, item3, item4] + items = [data] + let menuView = DropUpMenu(items: data, selectedRow: 0, bottomOffsetY: self.tabBarController?.tabBar.frame.height ?? 0) + menuView.delegate = self + menuView.showMenu() + } +``` + +#### Handle delegate + +```swift +extension ViewController: DropUpMenuDelegate { + func dropUpMenu(_ dropUpMenu: DropUpMenu, didSelectRowAt indexPath: IndexPath) { + let alertConroller = UIAlertController(title: "Nice", message: "DropUpMenu didselect \(indexPath.row) text:\(items[indexPath.section][indexPath.row].title)", preferredStyle: .alert) + let okAction = UIAlertAction(title: "OK", style: .cancel, handler: nil) + alertConroller.addAction(okAction) + present(alertConroller, animated: true) { + print("Display success") + } + } + + func dropUpMenuCancel(_ dropUpMenu: DropUpMenu) { + print("select cancel") + } +} +``` + + for detail, Please check the demo ## License