ios - Expected declaration error when adding subview -


hi got "expected declaration" error when tried add subview uiview, here's code:

@ibdesignable class timepickerview: uiview {  /* // override drawrect: if perform custom drawing. // empty implementation adversely affects performance during animation. override func drawrect(rect: cgrect) {     // drawing code } */       var borderwid = cgfloat(3.0)     let square = uiview()     square.frame = cgrect(x: 30, y: 30, width: 50, height: 50) //line of error     square.layer.bordercolor = uicolor.bluecolor().cgcolor     square.layer.borderwidth = borderwid     self.view.addsubview(square)  } 

you can declare instance variable/properties (and assign default values) in class outside of function cannot include other code.

all of lines of code after let square = uiview() need go in function, initialiser.


Comments

Popular posts from this blog

c# - Validate object ID from GET to POST -

node.js - Custom Model Validator SailsJS -

php - Find a regex to take part of Email -