所以我正在尝试制作一个VAT转换器,它获取滑块的增值税百分比,并将其应用于从UITextField获取的值,然后将其输出到另一个文本字段。我的按钮推动动作如下所示:
@IBaction func Calculate(sender: AnyObject){
var curentval = Int(Slider.value) // Get the vat % from the slider
var sum = Sum.text.toInt() //
var VAT = sum! * curentval/100 // this is what im trying to output in a text field that is called VAT
答案 0 :(得分:1)
你可以像这样使用
@IBOutlet weak var txtVat:UITextField!
@IBaction func Calculate(sender: AnyObject){
var curentval = Int(Slider.value) // Get the vat % from the slider
var sum = Sum.text.toInt()
var finalVal = sum! * curentval/100
txtVat.text = UInt8(finalVal)
}