Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

dantastic

macrumors 6502a
Original poster
Jan 21, 2011
572
678
I am working on a UIButton subclass. at one point I want to show an activity indicator inside the button. I'm thinking I'd just animage the titleLabel over to the side a small bit like so:

(this is inside a UIButton subclass)
Code:
	[UIView animateWithDuration:0.2 delay:0.0 options:UIViewAnimationOptionBeginFromCurrentState animations:^{
		self.titleLabel.transform = CGAffineTransformMakeTranslation(30, 0);
	} completion:nil];

The title label animates over to where it should be - but then it animates back!
However, if we so something like
Code:
	[UIView animateWithDuration:0.2 delay:0.0 options:UIViewAnimationOptionBeginFromCurrentState animations:^{
		self.titleLabel.transform = CGAffineTransformMakeRotation(0.4);
	} completion:nil];

the label animates to where it should be and it stays there.

If I apply the above translation code to any other object, say, the button itself!
Code:
- (IBAction)buttonPressed:(id)sender {
	
	[UIView animateWithDuration:0.2 delay:0.0 options:UIViewAnimationOptionBeginFromCurrentState animations:^{
		self.button.transform = CGAffineTransformMakeTranslation(-30, 10);
	} completion:^(BOOL finished) {
		
	}];
}

I get a more expected result tho. Is there something funny going on with UIButton subviews or am I missing something obvious?
 
Is it possible that in the drawRect for uibuttons it removes the label and re-draws it?

edit: just realized that might not make sense because you said the rotation stays put
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.