How to create a gradient layer view in swift?

The following snippet of code draws a gradient layer in iOS swift programming.