AladinWay / TransitionButton

UIButton sublass for loading and transition animation.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Corner radius won't return to original state

brunohenriquesk1 opened this issue · comments

If you set button corner radius programmatically it won't return to its original state.

I suggest under setOriginalState method set

self.layer.cornerRadius = layer.cornerRadius instead of self.cornerRadius , this way it will go back to original state if you set programmatically or via storyboard.

I will check this

I have tested in the demo project with this code:

    @IBOutlet weak var submitButton: TransitionButton!

    override func viewDidLayoutSubviews() {
        super.viewDidLayoutSubviews()
        submitButton.cornerRadius = 25
    }

And it works fine 

@AladinWay make sure you add a new button on the storyboard and set corner radius only programmatically. Just tried and I'm able to reproduce the same issue, the only way to fix it is doing what I mentioned above.

Yes, I have removed the cornerRadius from the storyboard in the example above. Can you please provide an example project based on the demo with the issue ?

on viewDidLoad I set self.nextButton.layer.cornerRadius = nextButtonHeight / 2
Going to provide an example project later on. Thanks

ezgif-5-3e53eb441da3

I have the same problem, have you found a solution?

I could not reproduce it. I will give it another try and will push a fix if needed.

@ivai96 yes! I was able to fix it. you'll have to edit the pod files, under setOriginalState method set self.layer.cornerRadius = layer.cornerRadius instead of self.cornerRadius , this way it will go back to original state if you set programmatically or via storyboard.

@brunohenriquesk1 @ivai96 can you please confirm if adding to TransitionButton.swift this line :

self.cornerRadius = layer.cornerRadius // cache cornerRadius before animation of spiner

in open func startAnimation()

just after

self.cachedImage = image(for: .normal) // cache image before animation of spiner

solves the issue for you ?

@brunohenriquesk1 @AladinWay Sorry for the late response, I have been reassigned to another project, but now that I am back I tested both solutions and they both work for me 👍 Thank you guys! :)