Creating a framework
As you know, sometimes we have code that is meant to be shared between an application, and the best way to do this is to create a framework. In this case, we are going to create a framework which should contain a customized view. For this recipe, we are going to add only one view. This view will be painted with a gradient. This way, you can change your application's background easily.
Getting ready
Create a new project called CustomViewsFramework
. To do this, go to File | New | Project, and then choose the Framework and Library section. Click on the Cocoa Touch Framework option, as shown in the following screenshot:
Select Swift as the project language.
How to do it...
Now, follow these steps to create a framework:
Start adding a new file to your project. In this case, you can choose the Cocoa Touch Class option from the Source section, as shown here:
Now you have to write the new class name, let's call it
CVGradientView
. Also make sure that a subclass ofUIView
is selected...