#2 擇偶條件 App
Published in
2 min readAug 9, 2019
目的:學習 IBOutlet、IBAction、SegmentControl、SliderControl、TextField
條件判斷的部分
- 姓名是女生的話顯示生氣的臉
- 身高太矮顯示嫌棄的臉
@IBAction func submit(_ sender: UIButton) { let gender = genderSegment.titleForSegment(at:
genderSegment.selectedSegmentIndex)
let height:Int = Int(heightLabel.text!) ?? 0
let constellation:String = constellationText.text!
if gender == “女”{
resultImage.image = UIImage(named: “3”)
} else if height < 175 || constellation.contains(“Virgo”){
resultImage.image = UIImage(named: “2”)
} else {
resultImage.image = UIImage(named: “1”)
}
}
另外還有實作了星座欄位的自動補齊功能,避免英文拼錯。
Github 網址