简体   繁体   中英

Stop text in a label with changing numbers from changing width in swift IOS

How do i stop text in a label from moving/changing size (being dynamic) when it has numbers that are changing every second.

var duration = //user input
func counting() {
    label.text = "\(duration)"
    if duration > 0 {
        duration -= 1
    } else if duration == 0 {
        //stop
}

The functions updates itself every second.

I have an label that have numbers counting down every second, but when it changes numbers the width changes to depending on how big the number is. How do i stop this and give every letter/number the same width. So i want an "1" to take as much space as an "5". I am not talking about the space between (margin) but rather the space inside (item/letter/number size).

Label text taking more space then if it had been 4:11

Label text taking less space then if it had been 3:56

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM