Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Corner radius won't return to original state #52

Open
brunohenriquesk1 opened this issue May 8, 2020 · 10 comments
Open

Corner radius won't return to original state #52

brunohenriquesk1 opened this issue May 8, 2020 · 10 comments

Comments

@brunohenriquesk1
Copy link

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.

@AladinWay
Copy link
Owner

I will check this

@AladinWay
Copy link
Owner

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 

@brunohenriquesk1
Copy link
Author

@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.

@AladinWay
Copy link
Owner

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 ?

@brunohenriquesk1
Copy link
Author

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

ezgif-5-3e53eb441da3

@ivai96
Copy link

ivai96 commented Jun 12, 2020

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

@AladinWay
Copy link
Owner

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

@brunohenriquesk1
Copy link
Author

brunohenriquesk1 commented Jun 12, 2020

@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.

@AladinWay
Copy link
Owner

AladinWay commented Jun 12, 2020

@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 ?

@ivai96
Copy link

ivai96 commented Aug 27, 2020

@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! :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants