mardi 12 mai 2015

Set random color for a cgfill in external function

I have a rectangle and I want to fill it with a random color.

The function for returning the random color should be seperate.

This is my idea but it does not work out, I think because of the type? Do I need to do this with pointers?

func getRandomColor() -> CGColorRef {
    let color = CGColorCreate(CGColorSpaceCreateDeviceRGB(), [1.0, 0.5, 0.5, 0.2])
    return color
}


func drawRect {
    // ...
    CGContextSetFillColorwithcolor(context,getRandomColor())
    // ...
}




Aucun commentaire:

Enregistrer un commentaire