zoukankan      html  css  js  c++  java
  • 类似刷新微博后,顶部显示更新数量的动画。

    @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

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

  • 相关阅读:
    帮助C#菜鸟进入SQL/XML开发
    汉字转换为拼音的函数
    水晶报表的使用技巧
    用DataSet操作XML
    frame,iframe,frameset 的区别(来源网络)
    oracle 数据库锁表解决方法
    c#日期类型的使用 (转)
    深入了解ViewState 深入了解ViewState
    js中top、parent、frame
    SQL中 inner join、 left join 、right join、 outer join之间的区别(来自百度自用)
  • 原文地址:https://www.cnblogs.com/rendaochoucheng/p/6531087.html
Copyright © 2011-2022 走看看