xcode - Swift 4 Functions Button properties -


i new swift. trying create func

func roundedbutton(buttonik: string) {            buttonik.clipstobounds = true     buttonik.layer.cornerradius = 10     buttonik.layer.maskedcorners = [.layermaxxminycorner, .layerminxminycorner, .layermaxxmaxycorner] } 

than call it

roundedbutton(buttonik: "buttontop") 

and have output

buttontop.clipstobounds = true buttontop.layer.cornerradius = 10 buttontop.layer.maskedcorners = [.layermaxxminycorner, .layerminxminycorner, .layermaxxmaxycorner] 

i getting these errors

value of type 'string' has no member 'clipstobounds' value of type 'string' has no member 'layer' 

thank :)

i think issue confusing name of button object represents button. change routine to:

func roundedbutton(button: uibutton) {            button.clipstobounds = true     button.layer.cornerradius = 10     button.layer.maskedcorners = [.layermaxxminycorner, .layerminxminycorner, .layermaxxmaxycorner] } 

then call passing button want apply these properties to... instead of passing string.


Comments

Popular posts from this blog

ubuntu - PHP script to find files of certain extensions in a directory, returns populated array when run in browser, but empty array when run from terminal -

php - How can i create a user dashboard -

javascript - How to detect toggling of the fullscreen-toolbar in jQuery Mobile? -