Set the class to StopwatchHand, and you should see the following:īuild and run your project to ensure that everything is lined up correctly, and that you are not seeing any Auto Layout errors or problems with your storyboard. Change the view’s background color to a clear color, and give it the following constraints: Now, drag a second view onto the scene for the stopwatch hand and size it to be the same size/location as the stopwatch. Because you marked the class as you’ll see a preview instantly! Update the frame of your view, and set the class to Stopwatch in the Identity Inspector. ![]() Delete the “First View” label as you won’t need that anymore.ĭrag a view into the scene for the stopwatch (the size and position doesn’t matter), and set the following constraints on this view: Open Main.storyboard you’ll be dealing with the Asset View Controller scene (the “First View”). Your next step is to set up views for each element in the storyboard. Open it and replace the contents with the following:Īs you can see, using StyleKits saves you save tons of code in your subclasses, and working with custom views becomes a breeze.īuild your project just to make sure that everything compiles correctly. Easy, eh? :]Ĭreate another new Swift file named StopwatchHand.swift. This uses the StyleKit helper code generated by PaintCode to draw the stopwatch body. Open it and replace the contents with the following: Once you’ve added the Swift file to your project, create a new Swift file named Stopwatch.swift.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |