How to add pinch-to-zoom to a text view on iOS

I'm up to my neck in work trying to get the site for Update Conference up and running but I saw a tweet in my stream from Mark Ford that I couldn't ignore.

Mark had written a blog post about how his wife finds it difficult to use some iOS apps because they do not implement a means to increase text size:

I have a particular bee in my bonnet when it comes to accessibility, my wife is registered blind and I am constantly frustrated when she is unable see things (like text on a screen) especially when I know that this is avoidable… What I don’t understand is why there is no way to change font size system wide, or why app developers don’t provide that facility. Yes I know that you can switch on zooming, but honestly – have you tried using zooming on a phone?

So I dutifully retweeted Mark's tweet – as you do – and went on battling with cross-browser issues for the site (you really get to appreciate how wonderful an experience it is to develop for a single platform when you go back to battling with cross-platform development). I also told Mark that in Feathers, you can pinch-to-zoom the tweet text in the main text view. (Goodness knows, having as custom UI as it has, Feathers has a long way to go in terms of accessibility itself.) Mark responded with: "ha! so text scaling is doable. Thanks @aral! care to explain how so others can follow suite?"

OK, Mark (and other iOS devs), here goes: it's actually really easy.

You simply create a pinch gesture recognizer and attach it to a text view. Then you adjust the font size (and hopefully persist it for next time so the user doesn't have to keep doing it every time she uses your app).

It's about as much code as it is to explain in English, so here's a snippet from Feathers:

I hope this helps and I hope seeing how simple it is to implement will mean that more developers will implement this in their apps. Thanks for bringing it to my attention, Mark.

Comments