当前位置: 移动技术网 > IT编程>移动开发>IOS > iOS UISwitch 设置默认为开,添加事件

iOS UISwitch 设置默认为开,添加事件

2018年11月09日  | 移动技术网IT编程  | 我要评论

剑网2灵气表,正午的死神,祁锦泓

ios uiswitch 设置默认为开,添加事件:ios uiswitch如何设置默认为开,添加事件呢?希望下面的文章对大家有所帮助。
#import"viewcontroller.h"

@interfaceviewcontroller()

@end

@implementationviewcontroller

- (void)viewdidload {

[superviewdidload];

uiswitch* swt = [[uiswitchalloc]initwithframe:cgrectmake(100,100,100,100)];

[self.viewaddsubview:swt];

[swtseton:yes];//默认是no关着

swt.thumbtintcolor= [uicolorpurplecolor];

[swtaddtarget:selfaction:@selector(tell)forcontrolevents:uicontroleventtouchupinside];

}

- (void)didreceivememorywarning {

[superdidreceivememorywarning];

// dispose of any resources that can be recreated.

}

- (void) ftaction{

nslog(@"hhh");

}

ui控件 uiswitch 设置默认为开,添加事件

- (void)open:(uiswitch*)swt{

if(swt.on) {ui控件 uiswitch 设置默认为开,添加事件

nslog(@"打开状态");

}else{ui控件 uiswitch 设置默认为开,添加事件

nslog(@"关闭状态");

}ui控件 uiswitch 设置默认为开,添加事件ui控件 uiswitch 设置默认为开,添加事件

}

ui控件 uiswitch 设置默认为开,添加事件

- (void)tell{

nslog(@"fas");

}

@end

 

如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!! 点击进行留言回复

相关文章:

验证码:
移动技术网