class ViewController: UIViewController {
var index1 = 0 ;
var index2 = 0 ;
let numString = "数字为:"
@IBOutlet weak var num1: UITextView!
@IBOutlet weak var num2: UITextView!
@IBAction func rollbutton(_ sender: Any) {
updateText()
}
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
updateText()
}
func updateText(){
index1 = Int.random(in: 1...6)
index2 = Int.random(in: 1...6)
print(index1)
print(index2)
num1.text = "\(numString) \(index1)"
num2.text = "\(numString) \(index2)"
}
}
网友评论