Pregunta

I have an UIBezierPath for shadows on an UIScrollView but the shadows are scrolling together with my scollview. Is there a way to fix the shadow but keep the ability to scoll?

Edit (Added Code):

UIScrollView *scroll = [[UIScrollView alloc] initWithFrame:viewcontroller.view.frame];

[[scroll layer] setMasksToBounds:NO];
[[scroll layer] setShadowOffset:CGSizeMake(-5, 1)];
[[scroll layer] setShadowOpacity:0.2];

UIBezierPath *path = [UIBezierPath bezierPathWithRect:[viewcontroller.view bounds]];
[[scroll layer] setShadowPath:[path CGPath]];

[viewcontroller.view addSubview:scroll];
¿Fue útil?

Solución

Ok, so i used a workaround to fix the issue. I am just resetting the Bezierpath after i change the contentsize of the scrollview:

Following code does the job.

UIBezierPath *path = [UIBezierPath bezierPathWithRect:CGRectMake(0, 0, [scroll contentSize].width, [scroll contentSize].height)];
[[scroll layer] setShadowPath:[path CGPath]];
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top