CocoaPods trunk is moving to be read-only. Read more on the blog, there are 19 months to go.

JKDropDown 1.0.4

JKDropDown 1.0.4

TestsTested
LangLanguage SwiftSwift
License MIT
ReleasedLast Release Oct 2017
SwiftSwift Version 3.0 3.0
SPMSupports SPM

Maintained by JKDropdown.



  • By
  • Janesh suthar

JKDropDown ios Swift dropdwon menu

JKDropDown is simple light weight Swift dropdown

Features

  • We can use dropdown easy in/out animation with up/down direction: dropDownObject.showJKDropDown(senderObject: buttonSelect, height: 180, arrayList: arrayIs , arrayImages: imageArray,buttonFrame:buttonFrame!,direction : "down")// you can set "up"

Usage

Import Localize at the top of each Swift file that will contain localized text. Add JKDropDownDelegate in your Class:

class ViewController: UIViewController,JKDropDownDelegate {}

Create CGRect variable which is used to getting Button frame:

 var buttonFrame : CGRect?

Create JKDropDown object

var dropDownObject:JKDropDown!

Assign values to buttonFrame with parent view:

buttonFrame = view.convert(buttonSelect.frame, to: view)//view is parent view (self.view)

Example usage

import UIKit
class ViewController: UIViewController,JKDropDownDelegate {
    @IBOutlet weak var buttonSelect : UIButton!
    var buttonFrame : CGRect?
    var dropDownObject:JKDropDown!
    var arrayIs : [String] = ["Edit","Love","Music","Location"]
    let imageArray = ["1","2","3","4"]
    override func viewDidLoad() {
        super.viewDidLoad()
        buttonSelect.addTarget(self, action: #selector(tapsOnButton), for: UIControlEvents.touchUpInside)
    }
    override func viewDidAppear(_ animated: Bool) {
        super.viewDidAppear(true)
        buttonFrame = view.convert(buttonSelect.frame, to: view)
    }
    func tapsOnButton() {
        if dropDownObject == nil {
            dropDownObject = JKDropDown()
            dropDownObject.dropDelegate = self
            dropDownObject.showJKDropDown(senderObject: buttonSelect, height: 180, arrayList: arrayIs , arrayImages: imageArray,buttonFrame:buttonFrame!,direction : "down")
            view.addSubview(dropDownObject)
            
        }
        else {
            dropDownObject.hideDropDown(senderObject: buttonSelect,buttonFrame:buttonFrame!)
            dropDownObject = nil
        }
    }
    func recievedSelectedValue(name: String, imageName: String) {
        dropDownObject.hideDropDown(senderObject: buttonSelect, buttonFrame: buttonFrame!)
        dropDownObject = nil
        buttonSelect.setTitle(name, for: .normal)
        var imageView : UIImageView?
        imageView = UIImageView(image: UIImage(named:imageName))
        imageView?.frame = CGRect(x: 5, y: 5, width: 25, height: 25)
        buttonSelect.addSubview(imageView!)
    }
}

License

JKDropDown is released under the MIT license. See LICENSE for details.