ios - What's the equivalent of CAGradientLayer in swift? -


i'm trying port on objective-c code creates gradient layer

cagradientlayer *gradientlayer = [cagradientlayer layer]; gradientlayer.colors = colors; gradientlayer.locations = locations; gradientlayer.frame = view.bounds;  [view.layer insertsublayer:gradientlayer atindex:index]; 

however in swift, cagradientlayer not seem have static 'layer' method or constructor. trying use type produces:

let a:cagradientlayer? = null 

error: use of module 'cagradientlayer' type

as far can tell, cagradientlayer not module can import. what's correct way of doing gradient layer in swift?

you need import quartzcore first:

import quartzcore  let a:cagradientlayer = cagradientlayer() 

Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

ios - Change Storyboard View using Seague -