YFPopupButtons 0.1.2

YFPopupButtons 0.1.2

TestsTested
LangLanguage SwiftSwift
License MIT
ReleasedLast Release Aug 2016
SPMSupports SPM

Maintained by yangfan.



  • By
  • pushian

YFPopupButtons

Demo Gif

Example

To run the example project, clone the repo, and run pod install from the Example directory first.

Installation

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

pod "YFPopupButtons"

How To Use

Initialization

var testView = YFPopupButtonsView()
testView.delegate = self

Core Functions

  • Display the button view and pop up the buttons.
testView.show()
  • Dismiss the button view and the buttons. Normally, the user does not have to call this function in their own code because there are alreay built in dismiss actions in the view.
testView.dismiss()

Delegate Functions

  • Indicate the total number of buttons.
func numOfItems(buttonsView: YFPopupButtonsView) -> Int
  • Indicate the maximum number of buttons allowed for display in a single row.
func maxNumberOfItemsInRow(buttonsView: YFPopupButtonsView) -> Int
  • Define the size for all the buttons.
func itemSize(buttonsView: YFPopupButtonsView) -> CGSize
  • Initialize and customize the buttons.
func buttonsView(buttonsView: YFPopupButtonsView, itemForIndex index: Int) -> YFPopupbotton

Example of Defining Round Buttons with Image and Title.

func buttonsView(buttonsView: YFPopupButtonsView, itemForIndex index: Int) -> YFPopupbotton {
    let button = YFPopupbotton(contentImage: UIImage(named: "fbIcon")!, title: "Title")
    button.contentImageView.layer.cornerRadius = 30
    button.contentImageView.backgroundColor = .whiteColor()
    button.contentImageView.contentMode = .ScaleAspectFill
    return button
}
  • Customize the actions triggered by clicking a certain button.
func buttonsView(buttonsView: YFPopupButtonsView, didTapItemAtIndex index: Int)
  • Define the space left between the left-most button/right-most button and the view.
func sideMargin(buttonsView: YFPopupButtonsView) -> CGFloat
  • Define the sapce between two rows of the buttons
func spaceBetweenRows(buttonsView: YFPopupButtonsView) -> CGFloat
  • Customize the actions triggered before the display of the buttons.
func buttonsViewWillAppear(buttonsView: YFPopupButtonsView)
  • Customize the actions triggered after the buttons being dismissed.
func buttonsViewWillDisappear(buttonsView: YFPopupButtonsView)

Author

pushian, [email protected]

License

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