Switch 设置颜色

2021-07-08  本文已影响0人  MJBaby

UISwitch设置自己想要的颜色,可以仿照以下处理

[[self.defaultSwitch rac_signalForControlEvents:UIControlEventValueChanged] subscribeNext:^(__kindof UISwitch * _Nullable x) {
        @strongify(self);
        if ([x isEqual:self.defaultSwitch]) {
            if (x.on) {
                [self.defaultSwitch setOnTintColor:UIColor.themeColor];
            } else {
                [self.defaultSwitch setTintColor:UIColor.normalColor];
                [self.defaultSwitch setBackgroundColor:UIColor.normalColor];
                [self.defaultSwitch.layer zl_radius:self.defaultSwitch.zl_height/2.0];
            }
        }
    }];
上一篇 下一篇

猜你喜欢

热点阅读