1

My plan is to render a custom waveform inside an UIScrollView (to allow user to pan and scroll through the waveform). But additionally I want to render additional non-zoomed information on top of the waveform (like play position marker, time, ...)

So I have a static UIImage that is the pre-rendered waveform, and some small bits that i have to render on top of it dynamically (I don't want the position marker or text to bee zoomed on the waveform).

I have read that UIImageView is the most efficient way to render a simple image (Most efficient way to draw part of an image in iOS), but that is not sufficient for me because i have to render something on top of it. Or is this somehow possible?

I dont see a way to use the UIScrollView for now, because it zooms everything inside right? But as mentioned, I need only the image zoomed, but the additional data non-zoomed.

Can I implement this using UIScrollView? Or do I have to implement a custom view that takes care of zooming and panning by itself?

Community
  • 1
  • 1
Martin Mlostek
  • 2,755
  • 1
  • 28
  • 57
  • What's wrong with just overlaying a `UIView` over the `UIScrollView` for your additional data? – Hamish Jan 18 '16 at 14:55
  • You mean rendering the content on an ```UIView``` on top and implementing the panning and zooming manually in it? While the ```UIScrollView``` will take care of zooming and panning for the ```UIImage```? Will this look tight or will there be glitches while zooming and panning? – Martin Mlostek Jan 18 '16 at 14:56
  • 1
    No, I mean adding your `UIImageView` to your `UIScrollView` and then overlaying the `UIView` over the scroll view. You shouldn't need zooming or panning in the `UIView`, as you said "*the additional data non-zoomed.*" If you need panning in the `UIView`, use two `UIScrollView`s on top of each other (one with zoom disabled).... or Alexander's solution (I didn't know that function existed) – Hamish Jan 18 '16 at 14:58
  • Ah okay. And well, the additional data is not zoomed by the scrollview (in order to avoid a change in the width of the play marker). But i need zoom and pan information in order to render the play position marker at the right position – Martin Mlostek Jan 18 '16 at 15:00
  • ah right... well you can always setup a delegate between the scroll view and the overlay to update it when zoom or panning changes. – Hamish Jan 18 '16 at 15:02
  • sounds good. thanks a lot, i will try that – Martin Mlostek Jan 18 '16 at 15:03

1 Answers1

0

If I understood your properly, you need to zoom one view(UIImageView) and prevent zooming another view (UILabel, for instance). So, you are wrong that Scroll View zoom everything inside it. UIScrollViewDelegate has method

optional func viewForZoomingInScrollView(_ scrollView: UIScrollView) -> UIView?

It should return view that should be zoomed. Hope, I helped you.