ios - Trouble creating a color in swift on Xcode using variables in a different class -
what wrong code? created variables in different class random values rgb color.
import uikit class graphics: viewcontroller { class color: uiview { override func drawrect(rect: cgrect) { let swiftcolor = uicolor(red: 1, green: 165/255, blue: 0, alpha: 1); let context = uigraphicsgetcurrentcontext() cgcontextsetlinewidth(context, 5.0) cgcontextsetstrokecolorwithcolor(context, uicolor(red: red1, green: green1, blue: blue1, alpha: 1.0))//.bluecolor().cgcolor) let rectangle = cgrectmake(60,170,200,80) cgcontextaddrect(context, rectangle) cgcontextstrokepath(context) cgcontextsetfillcolorwithcolor(context, uicolor(red: red, green: green, blue: blue, alpha: 1.0))//.redcolor().cgcolor) cgcontextfillrect(context, rectangle) } /* // override drawrect: if perform custom drawing. // empty implementation adversely affects performance during animation. override func drawrect(rect: cgrect) { // drawing code } */ } }
these error messages:
"graphics.type not have member named red"
"extra argument 'green' in call"
create instance of other class contains color variables
var colors = colorclass()
call colors instance
colors.green
Comments
Post a Comment