• Stars
    star
    1,335
  • Rank 33,788 (Top 0.7 %)
  • Language
    Swift
  • License
    MIT License
  • Created about 7 years ago
  • Updated about 5 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

✨ Awesome Dropdown menu for iOS with Swift 5.0

YNDropDownMenu

Awesome Version Carthage Compatible Docs License: MIT Build Status Platform Swift 5.0

Updates

See CHANGELOG for details

Introduction

The eligible dropdown menu for iOS, written in Swift 5, appears dropdown menu to display a view of related items when a user click on the dropdown menu. You can customize dropdown view whatever you like (e.g. UITableView, UICollectionView... etc)

demo demo2

Requirements

YNDropDownMenu written in Swift 5. Compatible with iOS 8.0+

Installation

Cocoapods

YNDropDownMenu is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod 'YNDropDownMenu'

Carthage

github "younatics/YNDropDownMenu"

Usage

import YNDropDownMenu

Init view with frame[CGRect], Views[UIView] and Titles[String]

let view = YNDropDownMenu(frame:frame, dropDownViews: dropDownViews, dropDownViewTitles: ["Apple", "Banana", "Kiwi", "Pear"])
self.addSubview(view)

done!

Inherit YNDropDownView (If you need)

class DropDownView: YNDropDownView {
   // override method to call open & close
    override func dropDownViewOpened() {
        print("dropDownViewOpened")
    }
    
    override func dropDownViewClosed() {
        print("dropDownViewClosed")
    }

    // Hide Menu
    self.hideMenu()

    // Change Menu Title At Index
    self.changeMenu(title: "Changed", at: 1)
    self.changeMenu(title: "Changed", status: .selected, at: 1)

    // Change View At Index 
    self.changeView(view: UIView(), at: 3)

    // Always Selected Menu
    self.alwaysSelected(at: 0)
    self.normalSelected(at: 0)
}

Customize

Show & Hide Menu

view.showAndHideMenu(at:1)

// When view is already opened
view.hideMenu()

Disable & Enable Menu

view.disabledMenu(at: 2)
view.enabledMenu(at: 3)

Always/Normal selected button label

view.alwaysSelected(at: 0)
view.normalSelected(at: 0)

Button Images with 3 situations (normal, selected, disabled)

view.setStatesImages(normalImages: [UIImage(named: "arrow_nor")], selectedImages: [UIImage(named: "arrow_sel")], disabledImages: [UIImage(named: "arrow_dim")])

Label color with 3 situations

view.setLabelColorWhen(normal: UIColor.black, selected: UIColor.blue, disabled: UIColor.gray)

Label font with 3 situations

view.setLabelFontWhen(normal: UIFont.systemFont(ofSize: 12), selected: UIFont.boldSystemFont(ofSize: 12), disabled: UIFont.systemFont(ofSize: 12))

BlurEffectView

// Enadbled or Disabled first (Default true)
view.backgroundBlurEnabled = false

// Use this line if you want to change UIBlurEffectStyle
view.blurEffectStyle = .light

// Or customize blurEffectView(UIView)
let backgroundView = UIView()
backgroundView.backgroundColor = UIColor.black
view.blurEffectView = backgroundView

// Animation end alpha
view.blurEffectViewAlpha = 0.7

Animation duration

view.showMenuDuration = 0.5
view.hideMenuDuration = 0.3

Animation velocity, damping

view.showMenuSpringVelocity = 0.5
view.showMenuSpringWithDamping = 0.8

view.hideMenuSpringVelocity = 0.9
view.hideMenuSpringWithDamping = 0.8

Change Menu Title At Index

view.changeMenu(title: "Changed", at: 1)
view.changeMenu(title: "Changed", status: .selected, at: 1)

Change View At Index

view.changeView(view: UIView(), at: 3)

Change Bottom Line

view.bottomLine.backgroundColor = UIColor.black
view.bottomLine.isHidden = false

Deprecated

extension YNDropDownMenu {
    @available(*, deprecated, message: "use init(frame: CGRect, dropDownViews: [UIView], dropDownViewTitles: [String]) instead")
    public init(frame: CGRect, YNDropDownViews: [YNDropDownView], dropDownViewTitles: [String])

    @available(*, deprecated, message: "use alwaysSelected(at index: Int) instead")
    open func alwaysSelectedAt(index: Int) {
        self.alwaysSelected(at: index)
    }
    
    @available(*, deprecated, message: "use disabledMenu(at index: Int) instead")
    open func disabledMenuAt(index: Int) {
        self.disabledMenu(at: index)
    }
    
    @available(*, deprecated, message: "use enabledMenu(at index: Int) instead")
    open func enabledMenuAt(index: Int) {
        self.enabledMenu(at: index)
    }

    @available(*, deprecated, message: "use showAndHideMenu(at index: Int) instead")
    open func showAndHideMenuAt(index: Int) {
        self.showAndHideMenu(at: index)
    }
}

extension YNDropDownView {
    @available(*, deprecated, message: "use changeMenu(title: String, at index: Int) instead")
    open func changeMenuTitleAt(index: Int, title: String) {
        self.delegate?.changeMenu(title: title, at: index)
    }
}

References

Please tell me or make pull request if you use this library in your application :)

Author

younatics Twitter

Thanks to

jegumhon

License

YNDropDownMenu is available under the MIT license. See the LICENSE file for more info.

More Repositories

1

MotionBook

📖 Awesome iOS UI/UX Application (Open Source)
Swift
1,474
star
2

YNSearch

🔍 Awesome fully customize search view like Pinterest written in Swift 5.0 + Realm support!
Swift
1,190
star
3

Highlighter

🖍 Highlight whatever you want!
Swift
930
star
4

ExpandableCell

✨ Awesome expandable, collapsible tableview cell for iOS written in Swift 5
Swift
761
star
5

MediaBrowser

🏞 A simple iOS photo and video browser with optional grid view, captions and selections written in Swift5.0
Swift
648
star
6

YNExpandableCell

✨ Awesome expandable, collapsible tableview cell for iOS written in Swift 4
Swift
454
star
7

Dismissable

⚡️Dismissable is super convenient to dismiss with gesture!
Swift
306
star
8

Triangulation

Triangulation effect in iOS
Swift
172
star
9

PowerMode

🎶 PowerMode in iOS!
Swift
169
star
10

MotionBook-Source

Official MotionBook Source Code
Swift
151
star
11

Toggler

💡 Don't further use 'isSelected' to every button. use 'Toggler' to simply control your buttons
Swift
105
star
12

React-Native-Integration-with-existing-app

React Native Integration with existing app
53
star
13

PickColor

📌 Pick color in image, make placeholder color like Pinterest!
Swift
53
star
14

DeepLearningToMobile

Curated way to convert deep learning model to mobile⚡️
Jupyter Notebook
49
star
15

AppUpdater

❗️Check your update and show alert with one line of code
Swift
49
star
16

Collection-Data-Structures-Swift-KR

Swift Data Structure를 소개합니다.
Swift
45
star
17

fastlane-ios-example

Fastlane iOS Example for Beta, Release
Ruby
37
star
18

Stringfication

🔨 Make all objects to String!
Swift
33
star
19

Objectification

🔍 Return objects where string is contained in object! (useful with Search)
Swift
21
star
20

Shader

🌃 Make simple shade view with Shader!
Swift
16
star
21

GirlFriend

Prevent 404
12
star
22

NumiOS

⚡️Numpy in iOS
Swift
9
star
23

AI-in-iOS

AI in iOS
6
star
24

younatics.github.io

younatics.github.io
HTML
5
star
25

avplayer-sample

Swift
4
star
26

GWExtensions

Extensions of iOS Develop
Shell
3
star
27

opensource-test

Test for opensource
Swift
2
star
28

algorithm

Swift
2
star
29

Apple_Korean_keyboard_bug_report

Objective-C
2
star
30

Using-Realm-in-MotionBook

Using Realm in MotionBook
1
star
31

React-Native-Review-KR

리액트 네이티브를 사용한 후기를 공유합니다.
1
star
32

FilterChart

Filter Chart for iOS
Swift
1
star