【发布时间】:2018-04-10 08:46:25
【问题描述】:
我有代码可以在计算器中显示历史记录,但符号(+、-、×、÷)取自“案例”(照片 1)
我怎样才能让历史中的符号(+,-,×,÷)由我设置的图片显示(照片2)
@IBAction func equalitySignPressed(sender: UIButton) {
if stillTyping {
secondOperand = currentInput
}
dotIsPlaced = false
addHistory(text: operationSign + displayResultLabel.text!)
switch operationSign {
case "+":
operateWithTwoOperands{$0 + $1}
case "-":
operateWithTwoOperands{$0 - $1}
case "×":
operateWithTwoOperands{$0 * $1}
case "÷":
if secondOperand == 0 {
Error.text = NSLocalizedString("Division by Zero", comment: "")
break
} else {
operateWithTwoOperands{$0 / $1}
}
default: break
}
}
添加历史记录:
func addHistory(text: String){
//Add text
resultLabelText.text = resultLabelText.text! + "" + text
}
【问题讨论】:
标签: ios swift calculator