1

I'm creating a label with font size 0 and i want to enlarge it and at the same time to make it disappear. One important thing is that i want to adjust the label size and place to the center and the view(it can be iphone or ipad). In my code I have to begin with a big font size, to have other suggestions?

My code:

UILabel* swipeLabel = [[UILabel alloc] initWithFrame:self.view.frame];
[swipeLabel setText:NSLocalizedString(@"Swipe to change", @"Swipe label text")];
[swipeLabel setTextColor:[UIColor whiteColor]];
[swipeLabel setTextAlignment:UITextAlignmentCenter];
[swipeLabel setFont:[UIFont systemFontOfSize:2]];
[swipeLabel setAdjustsFontSizeToFitWidth:YES];
[swipeLabel setBackgroundColor:[UIColor clearColor]];
[swipeLabel setNumberOfLines:1];

[self.view addSubview:swipeLabel];


[UIView animateWithDuration:1.5 delay:0 options:UIViewAnimationOptionAllowAnimatedContent animations:^{
     CGFloat scaleFactor = 10.0f;
     swipeLabel.transform = CGAffineTransformMakeScale(scaleFactor, scaleFactor);
    [swipeLabel setAlpha:0];
 } completion:^(BOOL finished) {

 }];

Thanks!

Alex Guberman
  • 203
  • 1
  • 3
  • 15
  • What exactly is wrong with the code you have? – woz Nov 01 '12 at 15:11
  • That's wrong it's that I have to start fron font size like 64 and I'm looking for the way to begin with 0 and enlarge it to 150 – Alex Guberman Nov 02 '12 at 12:12
  • Possible duplicate of [Can font size of UILabel be changed with smooth animation on iPhone?](http://stackoverflow.com/questions/2098893/can-font-size-of-uilabel-be-changed-with-smooth-animation-on-iphone) – mixel Sep 09 '16 at 15:37

1 Answers1

0
[UIView beginAnimations:nil context:nil];
label.transform = CGAffineTransformMakeScale(0.5,0.5);
[UIView commitAnimations];

This will make the size of font %50 smaller.

Ulaş Sancak
  • 887
  • 7
  • 22