zoukankan      html  css  js  c++  java
  • 新浪微博客户端(19)-显示刷新的最新微博数量

    HomeViewController.m

    /** 显示刷新微博数量 */
    - (void)showRefreshStatusesNums:(NSUInteger)nums {
    
        // 1. 创建提示label
        UILabel *label = [[UILabel alloc] init];
        label.width = [UIScreen mainScreen].bounds.size.width;
        label.height = 35;
        label.x = 0;
        label.y = 64 - label.height;
        label.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"timeline_new_status_background"]];
        label.textAlignment = NSTextAlignmentCenter;
        label.textColor = [UIColor whiteColor];
        label.font = [UIFont systemFontOfSize:16];
        
        if (nums == 0) {
            label.text = @"没有新的微博数据";
        } else {
            label.text = [NSString stringWithFormat:@"刷新了%zd条微博数据",nums];
        }
        
        // 2. 将当前label添加navigationBar的下面
        [self.navigationController.view insertSubview:label belowSubview:self.navigationController.navigationBar];
        
        // 2. 执行动画
        CGFloat duration = 1.0;
        [UIView animateWithDuration:duration animations:^{
            label.transform = CGAffineTransformMakeTranslation(0, label.height);
        } completion:^(BOOL finished) {
            [UIView animateWithDuration:duration delay:duration options:UIViewAnimationOptionCurveEaseInOut animations:^{
                label.transform = CGAffineTransformIdentity; // 清空当前transform
            } completion:^(BOOL finished) {
                [label removeFromSuperview]; // 清空当前label
            }];
        }];
        
    
    }

    最终效果:

  • 相关阅读:
    bzoj 1232 [Usaco2008Nov]安慰奶牛cheer
    bzoj 1237 [SCOI2008]配对 贪心+dp
    缺8数
    缺8数
    Binary GCD algorithm
    Binary GCD algorithm
    HDU1576 A/B (解法二)【试探法】
    HDU1576 A/B (解法二)【试探法】
    I00002 打印九九乘法表
    I00002 打印九九乘法表
  • 原文地址:https://www.cnblogs.com/yongdaimi/p/6036097.html
Copyright © 2011-2022 走看看