1

Hi I have a collection view which has collectionview cell with a outer stack view containing a uibutton and another stack view inside it.

It is a collapsible collection view as I click the uibutton in the cell, it must hide the inner stack view with animation. How to do this

Collection view cell
   Content view
     Stack view
        Uibutton
        Stack view

I want to hide the inner stack view with animation on selecting the UI button

Cell Code

func setupUI(_ hidden: Bool, filter: Filter) {

    self.filter = filter

    UIView.performWithoutAnimation {
        expandableStackView.isHidden = hidden ? false : true
        self.filterTitleButton.setTitle(filter.filterTitle, for: .normal)
    }
}

In Controller cell for row i will call this setUpUI function

Mohanraj
  • 587
  • 4
  • 21
  • show your tried code – Anbu.Karthik Jan 09 '20 at 10:34
  • @Anbu I updated the question please check. Hide is working fine and when I give without animation. But I want to unhide the stack view like it should slide to right on selected and go behind the button on unselected with slide left animation – Mohanraj Jan 09 '20 at 10:40

1 Answers1

0
UIView.animate(withDuration: 3,
                   delay: 0.0,
                   usingSpringWithDamping: 0.9,
                   initialSpringVelocity: 1,
                   options: [],
                   animations: {
                        innerStackView.hidden = true
                        stackView.layoutIfNeeded()
                    },
                   completion: nil)

also here is extension you can use https://stackoverflow.com/a/53517910/1780632

Jawad Ali
  • 13,556
  • 3
  • 32
  • 49