类似刷新微博后,顶部显示更新数量的动画。
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了类似刷新微博后,顶部显示更新数量的动画。相关的知识,希望对你有一定的参考价值。
@interface welcomeLabel : UILabel
+(void)setTopTipLabelWithFrame:(CGRect)frame name:(NSString *)name andNavController:(UINavigationController *)nav;
@end
#import "welcomeLabel.h"
@implementation welcomeLabel
+ (void)setTopTipLabelWithFrame:(CGRect)frame name:(NSString *)name andNavController:(UINavigationController *)nav{
id obj = [[welcomeLabel alloc]initWithFrame:frame name:name andNav:nav];
}
- (instancetype)initWithFrame:(CGRect)frame name:(NSString *)name andNav:(UINavigationController *)nav;
{
if (self = [super initWithFrame:frame])
{
[nav.view insertSubview:self belowSubview:nav.navigationBar];
self.text = [NSString stringWithFormat:@"欢迎回来,%@",name];
self.backgroundColor = [UIColor colorWithWhite:1.0 alpha:0.7];
self.textAlignment = NSTextAlignmentCenter;
self.textColor = [UIColor blackColor];
self.font = [UIFont systemFontOfSize:17];
[self setupLabel];
}
return self;
}
- (void)setupLabel
{
int w = self.bounds.size.width;
int h = 35;
int x = 0;
int y = 64 - h;
self.frame = CGRectMake(x, y, w, h);
CGFloat duration = 0.7;
self.alpha = 0.0;
[UIView animateWithDuration:duration animations:^{
self.transform = CGAffineTransformMakeTranslation(0, h);
self.alpha = 0.7;
} completion:^(BOOL finished) {
CGFloat delay = 1.5;
[UIView animateWithDuration:duration delay:delay options:UIViewAnimationOptionCurveEaseInOut animations:^{
self.transform = CGAffineTransformIdentity;
self.alpha = 0.0;
} completion:^(BOOL finished) {
[self removeFromSuperview];
}];
}];
}
@end
使用的时候 直接使用类方法即可。
以上是关于类似刷新微博后,顶部显示更新数量的动画。的主要内容,如果未能解决你的问题,请参考以下文章