Skip to content

A subclass of UIView which is capable of popping up buttons from the bottom of the view.

License

Notifications You must be signed in to change notification settings

pushian/YFPopupButtons

Repository files navigation

YFPopupButtons

CI Status Version License Platform

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.

About

A subclass of UIView which is capable of popping up buttons from the bottom of the view.

Resources

License

Stars

Watchers

Forks

Packages

No packages published