@IBAction func buttonPressed(_ sender: UIButton) {
if sender.tag == 1{
updateUI(storyNumber: 3)
}else if sender.tag == 2 {
updateUI(storyNumber: 2)
}
}
func updateUI(storyNumber: Int ){
storyTextView.text = story + (storyNumber)
topButton.setTitle(answer +(storeyNumber)+ a, for: .normal)
bottomButton.setTitle(answer +(storeyNumber)+ b, for: .normal)
}
我想知道如何在函数输入上更改变量名称?
答案 0 :(得分:0)
喜欢这个
func updateUI(storyNumber: Int ){
storyTextView.text = story + "\(storyNumber)"
topButton.setTitle(answer + "\(storyNumber)" + a, for: .normal)
bottomButton.setTitle(answer + "\(storyNumber)" + b, for: .normal)
}
如果a和b不是字符串那么
func updateUI(storyNumber: Int ){
storyTextView.text = story + "\(storyNumber)"
topButton.setTitle(answer + " \(storyNumber) " + "\(a)", for: .normal)
bottomButton.setTitle(answer + " \(storyNumber) " + "\(b)", for: .normal)
}
Also you can add spaced too...