SpreadsheetView icon indicating copy to clipboard operation
SpreadsheetView copied to clipboard

How to zoom the content when use pinch gesture?

Open Pr-Chen opened this issue 7 years ago • 6 comments

Pr-Chen avatar Dec 26 '17 03:12 Pr-Chen

There is no built-in feature to zoom by pinch gesture. You can add yourself. Probably add pinch gesture recognizer, then change number of column and row in the handler.

kishikawakatsumi avatar Dec 26 '17 04:12 kishikawakatsumi

@kishikawakatsumi Can you please explain a little more?

genaks avatar Feb 05 '18 04:02 genaks

@genaks Hi

You can add pinch gesture recognizer and add it to spreadSheetView then you can scale spreadSheadView like below:

@objc func zoom(sender:UIPinchGestureRecognizer) { if sender.state == .began || sender.state == .changed { self.spreadSheetView.transform = CGAffineTransform(scaleX: sender.scale, y: sender.scale) } else { if sender.scale < 1.0 { self.spreadSheetView.transform = CGAffineTransform.identity } } }

Cemoo avatar Jun 20 '18 14:06 Cemoo

@Cemoo Hi I followed your codes and had an issue. I couldn't scroll to top or bottom after zooming. Can you take a look?

zeldarose avatar Feb 14 '19 02:02 zeldarose

Works fine for me. Can I somehow have a look at your code?

genaks avatar Feb 15 '19 10:02 genaks

@IBAction func pinchRecognized(_ sender: UIPinchGestureRecognizer) { if sender.state == .began || sender.state == .changed { if sender.scale <= MAX_ZOOM_SCALE { self.transform = CGAffineTransform(scaleX: sender.scale, y: sender.scale) } } else { if sender.scale < 1.0 { self.transform = CGAffineTransform.identity } } }

My problem is couldn't scroll to the end of the spreadSheetView. My solution is putting the spreadSheetView into an UIScrollView then scaling the scrollview. Plz take a look. Thanks.

zeldarose avatar Feb 15 '19 10:02 zeldarose