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

Popular posts from this blog

database - VFP Grid + SQL server 2008 - grid not showing correctly -

jquery - Set jPicker field to empty value -

.htaccess - htaccess convert request to clean url and add slash at the end of the url -