Can't use variable to create custom swift color -


i'm trying use variables red, green, , blue create color random, error says can't convert variable type cgfloat.

import uikit var red = arc4random_uniform(8) + 1; var green = arc4random_uniform(8) + 1; var blue = arc4random_uniform(8) + 1;  let containerview = uiview(frame: cgrect(x: 0.0, y: 0.0, width: 300.0, height: 600.0))  let circle = uiview(frame: cgrect(x: 105.0, y: 215.0, width: 100.0, height: 100.0)) circle.layer.cornerradius = 50.0 let startingcolor = uicolor(red: (253.0/255.0), green: (159.0/255.0), blue: (47.0/255.0), alpha: 1.0) circle.backgroundcolor = startingcolor  containerview.addsubview(circle); 

try

let startingcolor = uicolor(red: cgfloat(red), green: cgfloat(green), blue: cgfloat(blue), alpha: 1.0) 

Comments

Popular posts from this blog

authentication - Mongodb revoke acccess to connect test database -

r - Update two sets of radiobuttons reactively - shiny -

ios - Realm over CoreData should I use NSFetchedResultController or a Dictionary? -