改变 UISwitch 边框厚度?

use*_*236 3 uiswitch ios

我在我的项目中使用 UISwitch 并已使用 成功更改了边框的颜色switch.tintColor。但是,笔画有点粗 - 有没有办法改变 UISwitch 上边框的宽度?

小智 5

您好,您可以设置开关的图层边框,这将为您提供所需的自定义,如下所示:

switch.layer.borderWidth = 1.0;
switch.layer.cornerRadius = 16.0;
switch.layer.borderColor = [UIColor whiteColor].CGColor;
Run Code Online (Sandbox Code Playgroud)