How to create uiscrollview with custom forms in ios?

I want to create a custom view with an image that can be scrollable and visible only in the shape I created (i.e. a triangle, oval, etc.)
I tried UIBezierPath, but its only mask is the image layer, but I want it as in UIScrollView, so the image also scrolls.
I want to complete this operation as quickly as possible, please offer me a technique or an example of how to do this. Thanks at Advance

+4
source share
1 answer

Here is what I will do. I just tried this and it works. All you have to do is add a mask to the view containing the scroll view as a preview. ( self in this case is the idea itself.)

 CAShapeLayer *maskLayer = [CAShapeLayer layer]; maskLayer.path = [UIBezierPath bezierPathWithRoundedRect:CGRectInset(self.frame, 5, 5) cornerRadius:50.0f].CGPath; self.layer.mask = maskLayer; 

Here is the gist of my working code: https://gist.github.com/rcdilorenzo/6437136

+3
source

Source: https://habr.com/ru/post/1500536/


All Articles