I have a multi-line UILabel that I want to enable zooming on.
I embedded it with a UIScrollView and set min zoom to .25 and max zoom to 4.
Here is something that I have come up with:
func scrollViewDidEndZooming(scrollView: UIScrollView, withView view: UIView?, atScale scale: CGFloat) {
label.font = UIFont(name: "YourFont", size: fontSize * scale)
label.transform = CGAffineTransformConcat(CGAffineTransformMakeScale(1 / scale, 1 / scale), CGAffineTransformMakeRotation(0))
}
Updated for Swift 4.0:
func scrollViewDidEndZooming(_ scrollView: UIScrollView, with view: UIView?, atScale scale: CGFloat) {
label.font = label.font.withSize(fontSize * scale)
label.transform = CGAffineTransform(scaleX: 1 / scale, y: 1 / scale).concatenating(CGAffineTransform(rotationAngle: 0))
}
And also remember that the label should be large enough to show the whole text. It sometimes takes a tiny bit to redraw, but this method is fairly simple.