How do I make a UISwitch under iOS 7 not take the background colour of the view behind it?

后端 未结 6 381
终归单人心
终归单人心 2021-02-02 11:27

It looks like this whenever off:

\"enter

While I\'d prefer more of a grey backgrou

6条回答
  •  走了就别回头了
    2021-02-02 11:45

    There's no API support for changing the off fill color of a UISwitch.

    Adjusting the tintColor will only affect the outline, and adjusting the backgroundColor will affect the whole frame, including the parts outside the rounded bounds.

    You either have to place a properly shaped opaque UIView behind it or - easier - use a custom open source implementation, such as MBSwitch, which allows you to set the off fill color.

提交回复
热议问题