수색…


통사론

  • (instancetype) initWithFrame : (CGRect) 프레임;
  • (void) setOn : (BOOL) on animated : (BOOL) animated;
  • (nullable instancetype) initWithCoder : (NSCoder *) aDecoder;

비고

1. UISwitch 참조 : Apple 설명서

여기에 이미지 설명을 입력하십시오.

2. 다른 참고 문헌 : Enoch Huang

여기에 이미지 설명을 입력하십시오.

설정 / 해제

목표 -C

[mySwitch setOn:YES];
//or
[mySwitch setOn:YES animated:YES];

빠른

mySwitch.setOn(false)
//or
mySwitch.setOn(false, animated: false)

배경색 설정

목표 -C

mySwitch.backgroundColor = [UIColor yellowColor];
[mySwitch setBackgroundColor: [UIColor yellowColor]];
mySwitch.backgroundColor =[UIColor colorWithRed:255/255.0 green:0/255.0 blue:0/255.0 alpha:1.0];
mySwitch.backgroundColor= [UIColor colorWithWhite: 0.5 alpha: 1.0];
mySwitch.backgroundColor=[UIColor colorWithHue: 0.4 saturation: 0.3 brightness:0.7 alpha: 1.0];

빠른

mySwitch.backgroundColor = UIColor.yellow
mySwitch.backgroundColor = UIColor(red: 255.0/255, green: 0.0/255, blue: 0.0/255, alpha: 1.0)
mySwitch.backgroundColor = UIColor(white: 0.5, alpha: 1.0)
mySwitch.backgroundColor = UIColor(hue: 0.4,saturation: 0.3,brightness: 0.7,alpha: 1.0)

색조 색 설정

목표 -C

//for off-state
mySwitch.tintColor = [UIColor blueColor];
[mySwitch setTintColor: [UIColor blueColor]];

//for on-state
mySwitch.onTintColor = [UIColor cyanColor];
[mySwitch setOnTintColor: [UIColor cyanColor]];

빠른

//for off-state
mySwitch.tintColor = UIColor.blueColor()

//for on-state
mySwitch.onTintColor = UIColor.cyanColor()

온 / 오프 상태에 대한 이미지 설정

목표 -C

//set off-image
mySwitch.offImage = [UIImage imageNamed:@"off_image"];
[mySwitch setOffImage:[UIImage imageNamed:@"off_image"]];

//set on-image
mySwitch.onImage = [UIImage imageNamed:@"on_image"];
[mySwitch setOnImage:[UIImage imageNamed:@"on_image"]];

빠른

//set off-image
mySwitch.offImage = UIImage(named: "off_image")

//set on-image
mySwitch.onImage = UIImage(named: "on_image")


Modified text is an extract of the original Stack Overflow Documentation
아래 라이선스 CC BY-SA 3.0
와 제휴하지 않음 Stack Overflow