0

I currently, I'd like to change FSCalendar's scope with animation using Snapkit.

The code below can replace scope with week and month. But the animation doesn't work.

    func calendar(_ calendar: FSCalendar, boundingRectWillChange bounds: CGRect, animated: Bool) {
            self.calendar.snp.updateConstraints { make in
                make.height.equalTo(bounds.height)
            }
        self.view.layoutIfNeeded()  
    }
bch7213
  • 1
  • 1

1 Answers1

0

Hard to say, without knowing your layout (is calendar a subview of a subview of a subview, for example?), but, in general, to animate constraints you want to "wrap" the .layoutIfNeeded() in an animation block.

Try this:

    self.calendar.snp.updateConstraints { make in
        make.height.equalTo(bounds.height)
    }
    UIView.animate(withDuration: 0.5, animations: {
        self.view.layoutIfNeeded()
        
    })
DonMag
  • 69,424
  • 5
  • 50
  • 86