如何将UILabel从小到原始大小设置动画?

时间:2015-06-11 08:03:13

标签: ios objective-c uilabel uianimation

其实我在我的应用程序中使用RESlider。在菜单表视图中有一个配置文件图像,除此之外还有一个通知标签。现在我想要的是,当用户按下汉堡菜单时,通知标签(带有999号码的橙色标签)应该从一个小点动画到原始大小。怎么实现这个? enter image description here

3 个答案:

答案 0 :(得分:2)

   myTextLabel.transform = CGAffineTransformMakeScale(0.3, 0.3);
[UIView animateWithDuration:2.0
                      delay: 0.1
                    options: UIViewAnimationOptionBeginFromCurrentState
                 animations:^{
                     myTextLabel.transform = CGAffineTransformMakeScale(1.5, 1.5); //grow
                 }
                 completion:^(BOOL finished){
                     myTextLabel.transform = CGAffineTransformMakeScale(1, 1);
                 }];

答案 1 :(得分:2)

将它放在viewDidAppear

-(void)viewDidAppear:(BOOL)animated{
     self.label.transform = CGAffineTransformMakeScale(0.01, 0.01);
    [UIView animateWithDuration:0.5 animations:^{
        self.label.transform = CGAffineTransformIdentity;
    } completion:^(BOOL finished) {

    }];
}

答案 2 :(得分:1)

更改标签的转换比例,如下所示:

[UIView animateWithDuration:0.5
                          delay:0.0
                        options:UIViewAnimationOptionAutoreverse | UIViewAnimationOptionRepeat | UIViewAnimationOptionCurveEaseInOut
                     animations:^{
                         timerLabel.transform = CGAffineTransformScale(timerLabel.transform, 0.7, 0.7);
                     }
                     completion:nil];