swift 如何停止现场活动时间四舍五入

j1dl9f46  于 2023-05-16  发布在  Swift
关注(0)|答案(1)|浏览(138)

我有一个带有计时器的活动,当isLuminanceReduced为true时,计时器向下舍入。
当计时器暂停在40:00而不是39:--时,如何使我的实时活动保持在40:00

struct TimerTextView: View {
    let range = Date()...Date().addingTimeInterval(1800)
    
    var body: some View {
        Text(timerInterval: range, pauseTime: range.upperBound)
    }
}

ajsxfq5m

ajsxfq5m1#

这个能用吗?

struct TimerTextView: View {
        let range = Date()...Date().addingTimeInterval(1800)
        let pauseTime = Date().addingTimeInterval(1800).rounded(.up, toNearest: 60) //Round up to the nearest minute
        
        var body: some View {
            Text(timerInterval: range, pauseTime: pauseTime)
        }
    }

如果没有,也许你有任何写作错误?

相关问题