I'm using UIScrollView
to create recording timeline just like Voice Memo app. This is horizontal scrollview's
frame at the beginning. I use CAShapeLayer
to draw bars.
scrlViewBars.frame = CGRectMake(0, scrlViewBars.frame.origin.y, SCREEN_WIDTH, 100);
....
[shapeLayer setPath:[[UIBezierPath bezierPathWithRoundedRect:CGRectMake(0, 0, barWidth, barHeight) cornerRadius:2] CGPath]];
[scrlViewBars.layer addSublayer:shapeLayer];
Recording starts and draws wave bars from beginning i.e wave bars are created from zero X position of UIScrollView
. When bars will reach to the half of the screen, I start moving UIScrollView
back by giving contentSize
and contentOffset
. So bars then will remain in centre after that just like Voice Memo app.
Everything works great except proper UIScrollView
timeline. If the recording is small, contentSize
will not be larger than screen width. So is it possible to UIScrollView
to go below 0 contentOffSet
? Because after recording is stopped, user can scroll timeline and starting content of recording should go till centre of the screen because there is a scrub bar at the centre which will not move and shows current recording time.