zoukankan      html  css  js  c++  java
  • iOS toast 的连续显示

    1. 新的 toast 来了, 如果当前的 toast 还没有结束, 需要停止当前的延迟计时器, 重新开启一个新的计时器.
    2. 新的 toast 来了, 会因为动画地显示而闪一下, 可以根据 toast 是否显示, 来确定是否需要添加动画.
       1 #pragma mark 隐藏视图
       2 - (void)hideSelfViewWithDelay{
       3     [self performSelector:@selector(hideSelfView) withObject:nil afterDelay:2];
       4 }
       5 
       6 - (void)cancelHideSelfViewWithDelay{
       7     [NSObject cancelPreviousPerformRequestsWithTarget:self selector:@selector(hideSelfView) object:nil];
       8 }
       9 
      10 
      11 /**
      12  更新 toast 提示, 重新延迟2秒显示
      13  */
      14 - (void)restartHideSelfViewWithDelay{
      15     [self cancelHideSelfViewWithDelay];
      16     [self hideSelfViewWithDelay];
      17 }
      18 
      19 
      20 - (void)hideSelfView{
      21     self.alpha = 1;
      22     [UIView animateWithDuration:0.25 animations:^{
      23         self.alpha = 0.1;
      24     } completion:^(BOOL finished) {
      25         self.hidden = YES;
      26     }];
      27 }
      28 
      29 
      30 /**
      31  如果已经显示, 就不添加动画
      32  */
      33 - (void)showSelfView{
      34     if (self.hidden == YES) {
      35         self.hidden = NO;
      36         self.alpha = 0.1;
      37         [UIView animateWithDuration:0.25 animations:^{
      38             self.alpha = 1;
      39         }];
      40     }
      41   
      42     [self restartHideSelfViewWithDelay];
      43 }
      44 
      45 - (void)dealloc{
      46     [self cancelHideSelfViewWithDelay];
      47 }
  • 相关阅读:
    umask设置导致的weblogic中的应用上传的文件没有权限打开
    顺序表查找及其优化(Java)
    前端能力要求
    CSS动画:旋转卡片效果
    CSS居中
    http服务器与https服务器的区别
    phpCURL抓取网页内容
    Node.js概述
    jQuery源码分析
    JavaScript学习书签
  • 原文地址:https://www.cnblogs.com/lz465350/p/9209877.html
Copyright © 2011-2022 走看看