📜  uilabel.text 来自数组字符串 - Swift 代码示例

📅  最后修改于: 2022-03-11 15:00:57.678000             🧑  作者: Mango

代码示例1
import UIKit

class ViewController: UIViewController {

var arrays = ["A", "b", "C", "D", "E", "F"]
var currentIndex = 0

@IBOutlet weak var ChangeText: UILabel!

override func viewDidLoad() {
    super.viewDidLoad()
    ChangeText.text = arrays[currentIndex]
}

@IBAction func Button() {
    currentIndex++
    if (currentIndex == arrays.count {
        currentIndex = 0
    }

    ChangeText.text = arrays[currentIndex]
}
}