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

Popular posts from this blog

java - WARN : org.springframework.web.servlet.PageNotFound - No mapping found for HTTP request with URI [/board/] in DispatcherServlet with name 'appServlet' -

android - How to create dynamically Fragment pager adapter -

html - Outlook 2010 Anchor (url/address/link) -