The use of parametrized vector images makes it easy to code effects that would be hard to achieve using bitmaps or traditional vector files. This is very handy when you want, say, the middle of a button to stretch horizontally, while keeping the sides a fixed size. You can also set up a shape so that it scales up and down from its initial dimensions in a predictable way, replicating the edge-inset resizing functionality offered by Cocoa classes like NSImage and UIImage. I couldn’t see designers switching away from the tools they’re already familiar with, and it seemed unlikely that a developer would want to deal with adding yet another piece of software to their toolchain only for the sake of gaining a rudimentary ability to manipulate graphic documents.įor example, you can define colors dynamically based on an initial set of constraints, which makes changing the overall tint of an image a matter of specifying an initial starting point-a great feature for user interface elements like buttons and icons. I must confess that the decision to incorporate an editor into the app had me a little confused at the beginning. The editor’s editor The app’s editor allows you to parametrize many aspects of your illustrations, making it easier to manipulate them in code. In my tests, I was able to successfully load a wide range of vector-based graphics-including both UI elements from some of the apps I have worked on and other files that were not designed with app development in mind.Īlmost without fail, PaintCode performed admirably in one case-an old file that had been exported to SVG from Adobe Illustrator and contained an odd font-I was forced to make a few tweaks in order for the import operation to succeed, but the app was otherwise able to load up even the most complex documents I could throw at it without skipping a beat. The first of these is probably the most straightforward: the app can import either standard SVG files or documents saved using Adobe Photoshop’s PSD format, although the latter requires an additional in-app purchase ($20). PaintCode provides three primary functions: importing existing vector documents (as well as creating new ones from scratch), editing them, and exporting them to a series of source files that can be used in a development project. Replace the contents of ViewController.PaintCode can handle most of the features supported by popular file formats like SVG. Your Xcode should now look similar to this: In the popup that appears, give your outlet the name viewForLayer. Click the Pin button, check Width and Height, make sure both values are set to 300, and click Add 2 Constraints.įinally, control-drag from the view you just created to the scene’s ViewController.swift file, right above the viewDidLoad() method.With that view still selected, click the Align button in the auto layout toolbar (bottom-right of the storyboard) and check Horizontal Center in Container and Vertical Center in Container, leave both their values set to 0, and click Add 2 Constraints. With it selected, go to the Size inspector ( View\Utilities\Show Size Inspector) and set x and y to 150 and width and height to 300. From the Object library, drag a View onto your View Controller Scene.Also, select Editor\Canvas\Show Bounds Rectangles, so that you can see the bounds outline of the view you’re about to add to your scene.Select View\Assistant Editor\Show Assistant Editor from the menu, and View\Utilities\Show Object Library if it’s not already displayed.In the Project navigator, select Main.storyboard.Okay, now you have the files set up and the next order of business is to create a view: Find a nice home for your project (I keep projects in a folder within my user directory called Source), and click Create.Uncheck Core Data is unchecked, then click Next.Select Swift for Language and Universal for Devices. Click Next, enter CALayerPlayground for the Product Name and enter an organization name and identifier of your choosing.Select iOS\Application\Single View Application from the dialog.Choose File\New\Project… from the menu.Ready to write some code? Good! Fire up Xcode and: So let’s start by creating a simple project from scratch to play around with layers. The easiest way to understand what layers are is to see them in action. You’ll be happy to know we have quite a few tutorials and books on the subject, such as Learn to Code iOS Apps with Swift andThe iOS Apprentice. Note: If you’re not quite there, no worries.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |