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

C# random value from dictionary and tuple -

cgi - How do I interpret URLs without extension as files rather than missing directories in nginx? -

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