1

我正在创建一个字体大小为 0 的标签,我想放大它,同时让它消失。一件重要的事情是我想调整标签大小和位置到中心和视图(它可以是 iphone 或 ipad)。在我的代码中,我必须从大字体开始,以获得其他建议?

我的代码:

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) {

 }];

谢谢!

4

1 回答 1

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

这将使字体 %50 的大小更小。

于 2012-11-01T21:57:23.110 回答