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 }
  • 相关阅读:
    20165212第八周学习总结
    20165212第八周课上测试补做
    20165212实验二面向对象程序设计
    Titanic生存预测
    聚类算法数据生成器make_blobs
    k-means
    监督学习、无监督学习与半监督学习
    在线Latex公式编辑器
    西瓜书课后习题——第四章
    ML经典数据集
  • 原文地址:https://www.cnblogs.com/lz465350/p/9209877.html
Copyright © 2011-2022 走看看