forked from organicmaps/organicmaps
[rating-view] [ios] Fixed rating view update delay.
This commit is contained in:
parent
545df162e5
commit
9c5facf6bd
1 changed files with 6 additions and 9 deletions
|
@ -308,6 +308,9 @@ import UIKit
|
|||
}
|
||||
|
||||
private var viewSize = CGSize()
|
||||
|
||||
var scheduledUpdate: DispatchWorkItem?
|
||||
|
||||
func updateImpl() {
|
||||
let layers = createLayers()
|
||||
layer.sublayers = layers
|
||||
|
@ -317,16 +320,10 @@ import UIKit
|
|||
frame.size = intrinsicContentSize
|
||||
}
|
||||
|
||||
@objc func doUpdate() {
|
||||
DispatchQueue.main.async {
|
||||
self.updateImpl()
|
||||
}
|
||||
}
|
||||
|
||||
func update() {
|
||||
let sel = #selector(doUpdate)
|
||||
NSObject.cancelPreviousPerformRequests(withTarget: self, selector: sel, object: nil)
|
||||
perform(sel, with: nil, afterDelay: 1 / 120)
|
||||
scheduledUpdate?.cancel()
|
||||
scheduledUpdate = DispatchWorkItem { self.updateImpl() }
|
||||
DispatchQueue.main.async(execute: scheduledUpdate!)
|
||||
}
|
||||
|
||||
override var intrinsicContentSize: CGSize {
|
||||
|
|
Loading…
Add table
Reference in a new issue