如何标签上添加动画? [英] How to add animations on label?

查看:139
本文介绍了如何标签上添加动画?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在ios的7工作我初学者对x code。我使用的故事板。通过点击从第1观点表中的任何行它进入第二视图,并打印该被点击行的截面和数量的数量。我想该标签在哪一行号印自带了从左侧或右侧或任何未来的动画。任何人都可以帮我吗?

I am working in ios 7. I am beginner to xcode. I am using storyboard. By clicking any row of table from 1st view it goes to 2nd view and prints the number of section and number of row which is clicked. I want that label in which row number is printed come with an animation like coming from left or right side or whatever. Can anyone help me with that?

推荐答案

可以使用 UIView的动画很容易达到这一目的。
用法取决于你如何把你的标签在屏幕上。

you can use UIView animation very easily for this purpose. The usage depends on how your are placing your label on screen.

1,如果你把它放在你的观点用故事板和您正在使用自动布局,您需要将约束在您的视图控制器的头文件链接到一个出口的动画恒定值。

1- if you've placed it on your view using storyboard and you are using auto layout, you need to link your constraint to an outlet in your view controller's header file for animating the constant value.

        [UIView animateWithDuration:0.2f animations:^{self.labelConstrint.constant=anyNumberoulike; 
        [self.view layoutIfNeeded]; 
        }];

2 - 如果你使用故事板没有自动排版(你应该),或者如果你正在创建你code标记,动画只是动画x或标签的框架矩形的Ÿ一部分。

2- if you are using storyboard without the auto layout (which you should) or if you are creating you label in code, the animation is simply animating the x or y part of the label's frame rect.

 [UIView animateWithDuration:0.2f animations:^{
self.label.frame=CGRectMake(finaLocationsX,self.label.frame.origin.y,self.label.frame.size.width, self.label.frame.size.height);
            }];

这篇关于如何标签上添加动画?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆