Ok, Im still new with protocols but I need to call a function (that I know works when called in the header class) from another class.
To do this, In the class from which Im calling the function (its a MSMessagesAppViewController) I have:
public protocol MSMessagesAppViewControllerDelegate: class {
func shrinkHeight(height:CGFloat)
func growHeight(height: CGFloat)
}
weak var delegate: MSMessagesAppViewControllerDelegate?
delegate?.shrinkHeight(height: 90)
Then I have in class HeaderCollectionReusableView: UICollectionReusableView, MSMessagesAppViewControllerDelegate
the actual functions:
func shrinkHeight(height:CGFloat)
{
print("WORKING!!"); //NOT printed
UIView.animate(withDuration: 0.7, delay: 0.0, usingSpringWithDamping:
0.6, initialSpringVelocity: 1.1, options: [], animations: {
//thing being animated
self.frame = CGRect(x: 0, y: 0, width: self.bounds.width, height: self.screenSize.height * (height/self.screenSize.height))
//change out
self.squareLogo.isHidden = true
self.logoLabel.isHidden = false
}, completion: { finished in
//code that runs after the transition is complete here
})
}
func growHeight(height:CGFloat)
{
It compiles but I know the functions above aren't called because no print statement. What am I doing wrong here?