Skip to content

Commit

Permalink
zero check
Browse files Browse the repository at this point in the history
  • Loading branch information
Kirow committed May 29, 2019
1 parent 419023a commit cd7ed8f
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions EFCountingLabel/Classes/EFCount.swift
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ public class EFCounter {

public var timingFunction: EFTiming = EFTimingFunction.linear
//works same way as CADisplayLink.frameInterval
//0 - max frame rate
public var refreshRateInterval: Int = 2

public var updateBlock: ((CGFloat) -> Void)?
Expand Down Expand Up @@ -112,11 +113,11 @@ public class EFCounter {

private func apply(interval: Int, to displayLink: CADisplayLink) {
if #available(iOS 10.3, *) {
displayLink.preferredFramesPerSecond = max(1, UIScreen.main.maximumFramesPerSecond / interval)
displayLink.preferredFramesPerSecond = interval > 0 ? max(1, UIScreen.main.maximumFramesPerSecond / interval) : 0
} else if #available(iOS 10.0, *) {
displayLink.preferredFramesPerSecond = max(1, 60 / interval)
displayLink.preferredFramesPerSecond = interval > 0 ? max(1, 60 / interval) : 0
} else {
displayLink.frameInterval = interval
displayLink.frameInterval = interval == 0 ? 1 : interval
}
}

Expand Down

0 comments on commit cd7ed8f

Please sign in to comment.