码迷,mamicode.com
首页 > 其他好文 > 详细

类似刷新微博后,顶部显示更新数量的动画。

时间:2017-03-10 16:18:44      阅读:124      评论:0      收藏:0      [点我收藏+]

标签:interface   font   insert   bool   rect   let   top   1.0   nav   

@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

 使用的时候 直接使用类方法即可。

类似刷新微博后,顶部显示更新数量的动画。

标签:interface   font   insert   bool   rect   let   top   1.0   nav   

原文地址:http://www.cnblogs.com/rendaochoucheng/p/6531087.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!