I'm making view that represent something like map, with pan and pinch gestures. At current moment it's implemented via overriden drawRect that called in handlePan with setNeedsDisplay. So, the resulting performance a little bit awkward. Is there any more appropriate approaches?
Asked
Active
Viewed 57 times
-1
-
1Have you had a look at the CATiledLayer class? It sound like this would solve your issue, but may be a bit more complicated. Documentation: https://developer.apple.com/library/ios/documentation/GraphicsImaging/Reference/CATiledLayer_class/index.html . There are a lot of tutorials on how to use it properly, just use a search engine :) – tomalbrc Dec 30 '14 at 21:21
1 Answers
0
So, more appropriate solution here is UIScrollView.
To get it work:
- Set up scrollView delegate, like
scrollView.delegate = self
- Implement
func viewForZoomingInScrollView(scrollView: UIScrollView) -> UIView?
{ return fieldView }
Optionally, you can set
scrollView.minimumZoomScale = scrollView.frame.width / fieldView.frame.width scrollView.maximumZoomScale = 2
Where fieldView is target custom view:
fieldView = FieldView(frame: frameRect)
scrollView.addSubview(fieldView)
scrollView.contentSize = frameRect.size

user1261347
- 315
- 2
- 15