Change color of UISwitch appwise

前端 未结 6 2078
孤独总比滥情好
孤独总比滥情好 2021-02-12 22:29

I am using UISwitch in iOS 3 to make a switch element in my app. It has default color set to blue, but I want to change its color to brown.

How can I choose

6条回答
  •  野趣味
    野趣味 (楼主)
    2021-02-12 23:06

    Currently you are limited to text values of On/Off or 0/1 for a UISwitch. You can customize the color by using tint. For further customization I would suggest something like what's been posted above going with a completely custom solution

    ex. [mySwitch setOnTintColor:[UIColor colorWithRed:0 green:175.0/255.0 blue:176.0/255.0 alpha:1.0]];

    source: http://www.raywenderlich.com/4344/user-interface-customization-in-ios-5

    EDIT: For iOS3, you are limited to a custom implimentation, I would suggest swapping two buttons with custom images. In later iOS versions you are given much more control and built in customization options.

提交回复
热议问题