Change color of UISwitch in “off” state

前端 未结 18 2768
忘掉有多难
忘掉有多难 2020-11-30 20:53

I\'ve learned that we can change the UISwitch button appearance in its \"on\" state, but is it also possible to change the color of the UISwitch in the \"off\" state?

18条回答
  •  南笙
    南笙 (楼主)
    2020-11-30 21:34



    Working 100% IOS 13.0 and Swift 5.0 switch both state color set same #ios13 #swift #swift5

    @IBOutlet weak var switchProfile: UISwitch!{
        didSet{
            switchProfile.onTintColor = .red
            switchProfile.tintColor = .red
            switchProfile.subviews[0].subviews[0].backgroundColor = .red
        }
    }
    

提交回复
热议问题