Swift 延迟执行dispatch_after

作者: 韦德460 | 来源:发表于2017-04-19 18:27 被阅读698次

    OC dispatch_after

    __weak typeof(self) weakSelf = self;
    dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^
    {
        __strong typeof(self) pThis = weakSelf;
        [pThis.backgroundView removeFromSuperview];
        pThis.backgroundView = nil;
    });
    

    Swift DispatchQueue.main.asyncAfte

    DispatchQueue.main.asyncAfter(deadline: .now()+0.5, execute: 
    {
        self.backgroundView()?.removeFromSuperview()
        self.setBackgroundView(backgroundView: nil)
    })
    


    强烈推荐:超简单!!! iOS设置状态栏、导航栏按钮、标题、颜色、透明度,偏移等

    https://github.com/wangrui460/WRNavigationBar
    https://github.com/wangrui460/WRNavigationBar_swift



    欢迎关注我的微博:wangrui460

    相关文章

      网友评论

      • _10_01_:谢谢,DispatchQueue 很好用。:+1:

      本文标题:Swift 延迟执行dispatch_after

      本文链接:https://www.haomeiwen.com/subject/hvuhzttx.html