dispatch_after中用的时间是纳秒,所以需要进行转换:desDelayInSeconds(目标时间,比如2s)* NSEC_PER_SEC
   double delayInSeconds = 0.3;
    
    // 创建延期的时间 0.3S,因为dispatch_time使用的时间是纳秒,尼玛,比毫秒还小,太夸张了!!!
    dispatch_time_t delayInNanoSeconds =dispatch_time(DISPATCH_TIME_NOW, delayInSeconds * NSEC_PER_SEC);
    dispatch_queue_t mainQueue = dispatch_get_main_queue();
    // 延期执行
    dispatch_after(delayInNanoSeconds, mainQueue, ^(void){
        [UIView animateWithDuration:0.3 animations:^{
            CGRect rect = self.postBtnBigRect;
            rect.origin.x = 0;
            
            self.topView.frame = rect;
        }];
    });

 

相关文章:

  • 2022-12-23
  • 2021-06-15
  • 2021-12-02
猜你喜欢
  • 2021-08-11
  • 2021-08-27
  • 2021-12-02
  • 2022-12-23
  • 2021-12-27
相关资源
相似解决方案