[英]how to create custom radio button on ui table view cell in swift
首先,您必須使所有按鈕背景清晰
func clearButtons() {
button1.backgroundColor = .clear
button2.backgroundColor = .clear
button3.backgroundColor = .clear
button4.backgroundColor = .clear
button5.backgroundColor = .clear
}
在viewDidLoad
或viewWillAppear
調用此 func 還使Ib-Action of all buttons
並在每個按鈕上調用此方法 Tapped IBAction forExample 如果按下 button1 你必須這樣做
@IBAction func Button1Tapped(_ sender: Any) {
clearButtons()
button1.backgroundColor = .white
}
您必須在所有按鈕操作中執行相同的操作並更改按下的按鈕名稱。
希望它的幫助....
您可以創建一個包含 collectionView(作為組件)的單元格,將其設置為單選並覆蓋 UICollectionViewCell 的 selected 方法以更改顏色和內容...
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.