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

UIButton & TOMSMorphingLabel #23

Open
vicc opened this issue Dec 12, 2014 · 5 comments
Open

UIButton & TOMSMorphingLabel #23

vicc opened this issue Dec 12, 2014 · 5 comments

Comments

@vicc
Copy link

vicc commented Dec 12, 2014

I would love to see UIButton's label support the morphing effect! Great job btw!

@cytryn
Copy link

cytryn commented Feb 6, 2015

+1

tried some quick hacking here but with no good results =/

@vicc
Copy link
Author

vicc commented Mar 13, 2015

@tomknig @cytryn Hadn't actually given this a try until now, but it's a fairly simple solution. At first glance your gut may be telling you to simply set your UIButton's titleLabel to your TOMSMorphingLabel, but as it so happens, a UIButton's titleLabel is readonly. However, by simply adding TOMSMorphingLabel as a subview of our UIButton, everything can still work beautifully. Don't add it as a subview of your UIButton's titleLabel though. How come? Well, when titleLabel.text is nil, it's frame is pretty much {{0, 0}, {0, 0}}, meaning your animatedLabel will randomly appear to disappear (or never show up since you'll probably always set the default label's text to nil.

Here's a quick code sample that should work out of the box (Make sure you define self.testButton though):

TOMSMorphingLabel *animatedButtonLabel = [[TOMSMorphingLabel alloc] init];
animatedButtonLabel.frame = self.testButton.bounds;
animatedButtonLabel.text = @"Your animated text goes here";
 [self.testButton addSubview:animatedButtonLabel];

Note: By setting your TOMSMorphingLabel's frame to it's superView's bounds (Your UIButton in this case) you can insure that it'll cover the entire button area. I would recommend setting it's background to clearColor, so that if you want to animate the touch of the button, it's still visible. @cytryn hope this helps.

@tomknig
Copy link
Owner

tomknig commented Mar 13, 2015

Great idea... 👍

@vicc
Copy link
Author

vicc commented Mar 16, 2015

@tomknig No problem. Anything to help. Maybe you could add an example in the demo and / or description for others to easily come across. 😎

@tomknig
Copy link
Owner

tomknig commented Mar 17, 2015

Cool! I'll do that as soon as possible and let you know! :)

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