Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

In which functions, how to add action in index cell of LiquidFloatingActionButton?

Tags:

ios

swift

I have created two button cells in LiduidFloatingActionButton with following code.

private func createFloatingButtons(){
    cells.append(createButtonCell("firstCell"))
    cells.append(createButtonCell("secondCell"))
    let floatingFrame = CGRect(x: self.view.frame.width - 56 - 16, y: self.view.frame.height - 56 - 36, width: 56, height: 56)
    let floatingButton = createButton(floatingFrame, style:.Up)
    self.view.addSubview(floatingButton)
    self.floatingActionButton = floatingButton
}

I don't know to add action in each cell of LiquidFloatingActionButton and also to display the name of cell. Please help me if anybody known about it.

like image 509
Kushal Shrestha Avatar asked Oct 17 '22 20:10

Kushal Shrestha


2 Answers

I got the solution for adding action on each cell.

extension CampaignListViewController: LiquidFloatingActionButtonDelegate {
func liquidFloatingActionButton(liquidFloatingActionButton: LiquidFloatingActionButton, didSelectItemAtIndex index: Int){
   // floatingActionButton.didTappedCell()
    switch(index){
    case 0:
        // do something
        break;

    case 1:
        // do somthing
        break;

    default:
        break;
    }

    self.floatingActionButton.close()
}
like image 84
Kushal Shrestha Avatar answered Oct 20 '22 23:10

Kushal Shrestha


Call this function in viewDidLoad(). Read this GitHub code you will get more idea. https://github.com/yoavlt/LiquidFloatingActionButton/blob/master/Example/LiquidFloatingActionButton/ViewController.swift

like image 37
iVarun Avatar answered Oct 20 '22 23:10

iVarun