我有在计算器中显示历史记录的代码,但符号(+、-、×、÷)取自“案例”(照片 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
}
最佳答案
不需要图像或属性字符串。您可以将 Unicode 字符 ⃣
(U+20E3 - Combining Enclosing Keycap)与各种数学符号一起使用:+
、-
、 ×
,÷
。 =
。
把这些放在一起得到:+⃣
,-⃣
,×⃣
,÷⃣
,=⃣
.
关于ios - 计算器中的历史记录用照片代替符号,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46997172/