ios - Make UIScrollView work only on content part, not "sides" -
here's scroll view (it gray area). content area yellow. notice insets, can scroll sides of content on middle of screen.
problem: can put finger on gray area , scroll it.
i want work can scroll putting finger on yellow content. if put finger on gray "background" , try scroll it, nothing should happen.
how this?
yellow content scrolled right, rests here:
yellow content scrolled left, rests here:
make subclass of uiscrollview
. give reference yellow view. override pointinside:withevent:
return false
unless point in frame of yellow view.
class myscrollview: uiscrollview { @iboutlet var yellowview: uiview? override func pointinside(point: cgpoint, withevent event: uievent?) -> bool { return yellowview?.frame.contains(point) ?? false } }
Comments
Post a Comment