【发布时间】:2012-11-01 15:03:40
【问题描述】:
我正在创建一个字体大小为 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) {
}];
谢谢!
【问题讨论】:
-
你的代码到底有什么问题?
-
错的是我必须从64这样的字体大小开始,我正在寻找从0开始并将其放大到150的方式