【UIKit-106-1】UISwitch - 基础使用

来源:互联网 发布:淘宝怎么让客服改价 编辑:程序博客网 时间:2024/05/18 11:49



创建

- (instancetype)initWithFrame:(CGRect)frame;             

        aSwitch = [[UISwitch alloc]initWithFrame:CGRectMake(111, 111, 111, 111)];   // 仅位置有效,大小无效。    [self.view addSubview:aSwitch];    



属性

@property(nonatomicretainUIColor *onTintColor NS_AVAILABLE_IOS(5_0) UI_APPEARANCE_SELECTOR;

@property(nonatomicretainUIColor *tintColor NS_AVAILABLE_IOS(6_0);

@property(nonatomicretainUIColor *thumbTintColor NS_AVAILABLE_IOS(6_0) UI_APPEARANCE_SELECTOR;

        aSwitch.onTintColor = [UIColor redColor];       // 选中底色    aSwitch.tintColor = [UIColor greenColor];       // 本身颜色(没选中时边框颜色)    aSwitch.thumbTintColor = [UIColor blueColor];   // 滑块颜色    



@property(nonatomic,getter=isOn)BOOL on;

    if (aSwitch.isOn) {        NSLog(@"1");    


开关

- (void)setOn:(BOOL)on animated:(BOOL)animated; 

    [aSwitch setOn:YES animated:YES];





开关
0 0
原创粉丝点击