Click here to Skip to main content
14,666,491 members
Rate this:
Please Sign up or sign in to vote.
See more:
is there any pod for giving shadow effects to buttons and other control in swift 4.2? Please help me with that! It's been only two weeks I started swift, and two weeks I spent for this!! Someone please help me!!.

What I have tried:

I have tried Material design MDKit! but doesn't worked in swift 4.2.
Updated 3-Jun-19 5:02am

1 solution

Rate this:
Please Sign up or sign in to vote.

Solution 1

Ash_savvy 4-Jun-19 3:09am
I appreciate your time and effort! Richard!, Thanks a lot!!. It worked for me.
But there is a small issue, which I'm not able to find a solution. I have created a custom class for shadow and assigned that to the appropriate button, shadow and rest everything is works fine, but the button title is not visible. Initially the button fill was white colour, and I change the fill color to my app's theme color (in Custom Class). Even I tried the setTitle property, but. :(
Richard MacCutchan 4-Jun-19 3:56am
Sorry, but I do not know Swift.
Ash_savvy 4-Jun-19 8:24am
Not a Problem! I fixed it! thanks a lot! :)
Ash_savvy 4-Jun-19 8:27am
extension UIButton{

func setShadow(){
layer.shadowColor = UIColor(red: 0, green: 0, blue: 0, alpha: 0.7).cgColor
layer.shadowOffset = CGSize(width: 0, height: 3)
layer.shadowOpacity = 1.0
layer.shadowRadius = 10.0
layer.masksToBounds = false

this code works! write it in extensions class so that we can call the function with a UIButton ref.
Like MyButton.setshadow()

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100