iOS 将图像设置为开/关状态

示例

目标C

//衬托图片
mySwitch.offImage = [UIImage imageNamed:@"off_image"];
[mySwitch setOffImage:[UIImage imageNamed:@"off_image"]];

//设置图像
mySwitch.onImage = [UIImage imageNamed:@"on_image"];
[mySwitch setOnImage:[UIImage imageNamed:@"on_image"]];

迅速

//衬托图片
mySwitch.offImage = UIImage(named: "off_image")

//设置图像
mySwitch.onImage = UIImage(named: "on_image")