計算BMI app
Published in
Mar 26, 2022
現在生活越來越多人在乎完美身材了,也越吃越清淡健康了
當然會越來越需要計算BMI的工具
//用來計算BMI值
@IBAction func RUN(_ sender: Any) {
if let heightText = heightTextField.text,
let weightText = wigthTextField.text,
let height = Double(heightText),
let weight = Double(weightText) {
let heightMeter = height / 100
let bmi: Double = weight / (heightMeter * heightMeter)
BMI.text = String(format: "%.1f", bmi)
}
附上GitHub