nghialv / MaterialKit

Material design components for iOS written in Swift
MIT License
2.5k stars 289 forks source link

MKTextField Ripple effect #31

Open ed-mejia opened 9 years ago

ed-mejia commented 9 years ago

If you add a MKTextField into a ScrollView or TableView, ripple effect does not play on tap, how can we solve this issue?

mollywoodnini commented 8 years ago

ScrollViews / TableViews swallow all the touches of any subviews. You have to subclass UIScrollView and pass the touches to the MKTextField like this:

override func touchesShouldBegin(touches: Set<UITouch>, withEvent event: UIEvent?, inContentView view: UIView) -> Bool {
        if let textField = view as? MKTextField, let touch = touches.first {
            textField.beginTrackingWithTouch(touch, withEvent: event)
        }

        return true
    }