PMSuperButton icon indicating copy to clipboard operation
PMSuperButton copied to clipboard

No shadow, background image and animation when added programatically

Open perunworks opened this issue 6 years ago • 2 comments

Hi, I'm adding buttons programatically. This is what I have and I can't seem to get the background image, shadow and animation working. All works when I add a button in storyboard view.

            let button = PMSuperButton() //UIButton()
            let bgrImage = UIImage(named: "someImage")
            //button.setImage(bgrImage, for: .normal) //-> this works ok
            button.setBackgroundImage(bgrImage, for: UIControl.State.normal)
            

            button.shadowColor = UIColor.gray
            button.shadowOffset = CGSize(width: 2, height: 2)
            button.shadowRadius = 2
            button.shadowOpacity = 2
            button.animatedScaleWhenSelected = 1
            button.animatedScaleWhenHighlighted = 1
            button.animatedScaleDurationWhenSelected = 1
            button.animatedScaleDurationWhenHighlighted = 1

Any idea what am I doing wrong?

perunworks avatar Jul 28 '19 02:07 perunworks

Do you also declare it using Storyboard (do you re-initialize the button)?

pmusolino avatar Aug 18 '19 14:08 pmusolino

No, I don't re-initialize it in Storyboard. I just create it programatically.

perunworks avatar Aug 27 '19 14:08 perunworks