ios - Custom variable 'layer' used before being initialized -
i create custom calayer set items corner radius.
func getlayercorner(radius:cgfloat) -> calayer { let layer:calayer layer.cornerradius = radius layer.maskstobounds = true return layer }
i'm getting variable 'layer' used before being initialized
i'm still learning swift , not sure how init it.
the error states wrong code. need initialise layer before using:
func getlayercorner(radius:cgfloat) -> calayer { let layer = calayer() layer.cornerradius = radius layer.maskstobounds = true return layer }
Comments
Post a Comment