RXSwift 忽略时间间隔 throttle

来源:互联网 发布:c语言求最大公约数算法 编辑:程序博客网 时间:2024/06/05 06:21


//throttle(0.3, scheduler: MainScheduler.instance)  0.3后执行点击事件   MainScheduler.instance  在主线程执行

   let btn =UIButton.init(frame:CGRectMake(0,100,width,50))

        

        btn.rx_tap

            .throttle(0.3, scheduler:MainScheduler.instance)

            .subscribeNext{

        

            print("点击")

        

        }.addDisposableTo(self.bag)

        

        btn.backgroundColor =UIColor.purpleColor()

        

        view.addSubview(btn)


0 0
原创粉丝点击