     }
     
     public func textFieldShouldClear(_ textField: UITextField) -> Bool {
-        if let result = delegate?.searchBarShouldClear?(self) where result {
+        if let result = delegate?.searchBarShouldClear?(self) {
             return result
         }
         return true
     }
     
     public func textFieldShouldReturn(_ textField: UITextField) -> Bool {
-        if let result = delegate?.searchBarShouldReturn?(self) where result {
+        if let result = delegate?.searchBarShouldReturn?(self) {
             return result
         }
         return true

let kDefaultAnimationDuration: NSTimeInterval = 0.25

public class SHSearchBar: UIView, UITextFieldDelegate {
    private var backgroundView: UIImageView = UIImageView()

    public var cancelButton: UIButton = UIButton(type: .Custom)
    public var textField: UITextField = UITextField()

    // Constraints for showing and hiding the cancel button
    private var bgToCancelButtonConstraint: NSLayoutConstraint!
    private var bgToParentConstraint: NSLayoutConstraint!
    
    public var delegate: SHSearchBarDelegate?
    

    // MARK: - UITextFieldDelegate
    
    public func textFieldShouldBeginEditing(_ textField: UITextField) -> Bool {
        if let result = delegate?.searchBarShouldBeginEditing?(self) {
            if result {
                setCancelButtonVisibility(true)
            }
            return result
        }
        setCancelButtonVisibility(true)
