Created
November 25, 2014 19:45
-
-
Save bmnick/dd7f570753ed32852576 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import UIKit | |
| /** | |
| A specialized scroll view that allows clicking through a trailing section of it's content. This is used for a | |
| transparent section at the end of the target rows that can be tapped through. It simply reports any points | |
| within the last `clickThroughOffset` points of the view as not belonging to the view. | |
| */ | |
| private class BNOffsetClickThroughScrollView: UIScrollView { | |
| /** | |
| The number of points at the right side of the scroll view that do not belong to the view. | |
| */ | |
| var clickThroughOffset: CGFloat = 44.0 | |
| /** | |
| This is used by the framework to determine if a point is within the given view. In our override, we report | |
| points in the last `clickThroughOffset` of the view as not being inside the scroll view. | |
| */ | |
| override func pointInside(point: CGPoint, withEvent event: UIEvent?) -> Bool { | |
| let hitPosition = contentOffset.x + point.x | |
| if super.pointInside(point, withEvent: event) && hitPosition < maxTappableX() { | |
| return true | |
| } else { | |
| return false | |
| } | |
| } | |
| /** | |
| Returns the maximum location that is within the view. | |
| */ | |
| func maxTappableX() -> CGFloat { | |
| return contentSize.width - clickThroughOffset | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment