How to insert a sublayer in swift? -
i creating view , adding gradient layer it.
i have this:
import uikit import quartzcore let rect : cgrect = cgrectmake(0,0,320,100) var vista : uiview = init(frame: rect) let gradient : cagradientlayer = cagradientlayer() gradient.frame = vista.bounds let cor1 = uicolor.blackcolor().cgcolor let cor2 = uicolor.whitecolor().cgcolor let arraycolors = [cor1, cor2] gradient.colors = arraycolors
now have this
[view.layer insertsublayer:gradient atindex:0];
how do in swift?
you can use following snippet
view.layer.insertsublayer(yourlayer, atindex: yourindex)
Comments
Post a Comment