Convert square blocks to Zawgyi with iOS8 Action Extension

Apple introduced tons of great additions to iOS experience and Extensions framework was one of the new features that I’m most excited about. Before iOS8, we could not integrate our apps with others. With iOS8, we can now integrate our apps with others to a certain extent. Here are 5 different types of extensions that app developers can now make -

  1. Today extensions (Widgets)
  2. Share extensions (For integration with Share sheet)
  3. Photo Editing extensions (Yay! Going to see a lot more integrated VSCO(http://instagram.com/vsco).
  4. Storage Provider extensions (Good news for Box, Dropbox, Drive and etc)
  5. Action extensions (This is the most interesting)

Let’s look at Action extensions. Basically, they allow apps to manipulate content from another app within the app itself. For instance, as part of WWDC demo, you can now translate a webpage without ever leaving safari.

There are two types of Action extensions -

  1. View Controller (E.g. Quickly launch a view controller to add a filter to any photo within another app)
  2. Extension Request Handling (E.g. Translating text within another app without showing any UI to the user)

For this Zawgyi extension, we’re using the second method. You can check out the demo video below -

It’s interesting to see how you can use Javascript while writing for an extension. Here’s the actual code snippet that injects Zawgyi into a webpage.

var doc = document.createElement('link');

doc.href = "http://mmwebfonts.comquas.com/fonts/?font=zawgyi";

doc.rel = "stylesheet";

document.head.appendChild(doc);

document.getElementsByTagName("body")[0].style.fontFamily = "zawgyi-one";

(Note: try to use VanillaJS more)

You can check out the full source code at GitHub (https://github.com/yemyat/Zawgyi-Action-Extension).

 
16
Kudos
 
16
Kudos

Now read this

Business Plan Starter Kit

As a first-time startup founder, it’s quite overwhelming when it comes to preparing paperwork for your first round of funding. Here is a sample structure that has helped me. 1. Pitch Deck Problem Solution How It Works Market Business... Continue →