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
Post a Comment