【问题标题】:Swift - WatchKit: Setting background color for selected row on table (WKInterfaceTable)Swift - WatchKit:为表格上的选定行设置背景颜色(WKInterfaceTable)
【发布时间】:2022-01-26 18:48:35
【问题描述】:

Swift - WatchKit:如何为手表表上的选定行设置背景颜色? 提前谢谢

【问题讨论】:

    标签: swift watchkit watchos wkinterfacetable


    【解决方案1】:

    将背景设为组

    @IBOutlet weak var cellBackGroup: WKInterfaceGroup!
    

    然后设置

    row.cellBackGroup.setBackgroundColor(UIColor.red)
    

    你可以保留一个变量

    var selectedIndex = 0
    

    并实现委托方法

    func table(_ table: WKInterfaceTable,  didSelectRowAt rowIndex: Int) {
        selectedIndex = rowIndex
        ....
    }
    

    【讨论】:

    • 好的,谢谢,我知道,但我如何才能将颜色设置为我选择的单元格?
    • se 编辑............
    • 谢谢;在你的帮助下我做到了:)
    • @RezaKashkoul 如果有帮助,您可能会接受答案
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-12-29
    • 2018-08-01
    相关资源
    最近更新 更多