I didn’t know about swiftify.co. What a great idea! Having said that, in my opinion, it’s a good idea to muddle through Objective C sites because there are a lot of valuable Objective C tutorials and projects out there. And in most cases, it’s a simple translation.
that’s a good point… I’m trying not to fill my head with too much C but perhaps a little wouldn’t be horrid. I’m still interested in finding out how to make a blek (app) style line, taking advantage of all the coalescing touches and so forth.
also interesting to me is the audio synth abilities of iOS, especially by making the sounds blek does when drawing…
I'd like the drawn image to stay the same size in both portrait and landscape.
The code works great for when the ContentMode is set to .ScaleToFill.
But if I set the ContentMode to a non-scaled mode like .TopRight and rotate the screen, the image proportions change when touchesMoved is fired. I think it has to do with placing the drawingImage into the context using a bounds that was different from the previous rotation, but I can’t figure out how get it to draw with the correct proportions.
I’ve tried storing and using a previous bounds (before rotation), setting the ContentMode before and after adding the drawingImage to the context, and even looking at manipulating cg/ci Image data using extent, etc…
That’s where the painted view does not rotate, but any other views do. If you just want to turn off rotation for the whole app, you can do it in the Project Target settings as the Scribble starter project does.
Thank you. I didn’t think of using CGAffineTransform!
I did remove auto layout for the canvas view and set the contentMode to topRight (and extended the view so that it covers both landscape and portrait). But was hoping that there was some trick with drawing into the context.
Hi Caroline. I wanted to thank you too for this very valuable tutorial. I had no problems building a swift drawing app as an exercise. I am stuck for now with an Objective-C drawing engine in my main project. I cant seem to find a tutorial as in-depth as yours based in ObjC. Is there a reason for that? I wonder if you point me (semi-pun) in the right direction.
Edit: The reason for no Objective-C is that Swift is the way forward. There will still be a large code-base of Objective-C apps, but companies are gradually switching to Swift. It’s faster to run (generally) and faster to code (once you know the language).
You are right of course. Time to change the engine to a swift based version. I hope the client will go for that. I’ll look through the tute list to see if something will make it easier. I do appreciate you getting back to me…