Keep Calm contains 1000 custom crowns that you can replace the crown at the top of the poster with (as well as the option for images and emoji). In previous versions these have always been @2x PNG files and they took up about 70% of the app's bundle size. This has been fine up until now, but with the @3x iPhone 6+ I really needed to improve the quality.
Now Keep Calm ships mostly with PNGs still but many of the more common crowns have been replaced with vector paths instead. These vectors have been produced by:
- Taking the original SVG file and simplifying it down to one path using Sketch
- Converting strokes to filled paths
- Exporting each crown as an SVG file
- Running a custom C program on each SVG file to produce binary encoded path data, which is then stored in an SQLite database
- Keep Calm loads the binary path data from SQLite and decodes it using a custom UIBezierPath extension
- Paths are rendered in a custom view using the appropriate color
As the binary encoded path data is fairly efficient the app's bundle size will slowly decrease as I convert more crowns to the new format, but more importantly the quality of the rendered crowns on screen will vastly improve.
Core Image colorization
As well as being able to change the crown in Keep Calm, you can also change the color of it. In older versions of the app the white crown PNGs were filtered using a CIColorMatrix filter. Unfortunately, despite having the math right, the produced color was always slightly different from the text. It was usually fine for gray scale colors, but anything else would be off by ±5%. I'm still yet to establish why this occurred, but there was an easy work around.
I now create a plain CIImage which represents a single color. Then I apply a mask to that image using the alpha channel of the crown image. The result is a correctly colored crown image.
This bug has been in Keep Calm for nearly two years, so I'm delighted to finally fix it once and for all.
Supporting iOS 7 and 8
Keep Calm 4.x will continue to support iOS 7 into the foreseeable future. I'm not depending on any iOS 8 features like extensions, so it makes sense to support iOS 7 still. Furthermore, given that iOS 8 adoption is slower than iOS 7 it will be a while until the majority of my customers are on iOS 8. A key factor I have to consider is that the vast majority of Keep Calm users tend to be children, so devices like the iPod touch and 16GB iPhones make up the majority of my users. These devices may not have been updated to iOS 8 in fears that it will slow them down or that it requires too much free storage space.
This update doesn't contain any Swift because it was primarily written against the iOS 7 SDK in about July (I was slow releasing it because of the extra work of vectorizing crowns). I'm pretty sure that I will begin to use Swift more over the next few months, but for now I'm restricting it to where I'm creating new classes.
Keep Calm on iOS remains a priority for me over the Android version. Over the next few months I'll be adding more vector crowns and bug fixes. The next update (probably 4.1) will likely be a 'Snow Leopard' style release where changes are primarily just fixes and minor improvements rather than major new features.
About half of all of the code in Keep Calm is in my private shared framework that I use across my apps. I've finally begun cleaning it all up and putting it in separate modules, so it is actually reasonably likely that it will be fully open sourced in the next few months :).