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:

enter image description here

yellow content scrolled left, rests here:

enter image description 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

Popular posts from this blog

ios - RestKit 0.20 — CoreData: error: Failed to call designated initializer on NSManagedObject class (again) -

java - Digest auth with Spring Security using javaconfig -

laravel - PDOException in Connector.php line 55: SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: YES) -