문제

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];
도움이 되었습니까?

해결책

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]];
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top