三种扁平化设计风格的UISwitch

源文件支持交流修改使用

开发语言:

分类:其他系统

    分享到:

源码搜索

  • 详情介绍 - 【三种扁平化设计风格的UISwitch】
- (void)viewDidLoad
{
    [super viewDidLoad];
     
    ibSwitch.onColor = [UIColor colorWithRed:0.20f green:0.42f blue:0.86f alpha:1.00f];
    ibSwitch.on = YES;
     
    // this will create the switch with default dimensions, you'll still need to set the position though
    // you also have the option to pass in a frame of any size you choose
    SevenSwitch *mySwitch = [[SevenSwitch alloc] initWithFrame:CGRectZero];
    mySwitch.center = CGPointMake(self.view.bounds.size.width * 0.5, self.view.bounds.size.height * 0.5);
    [mySwitch addTarget:self action:@selector(switchChanged:) forControlEvents:UIControlEventValueChanged];
    [self.view addSubview:mySwitch];
     
    // turn the switch on
    mySwitch.on = YES;
     
    // Example of a bigger switch with images
    SevenSwitch *mySwitch2 = [[SevenSwitch alloc] initWithFrame:CGRectMake(0, 0, 100, 50)];
    mySwitch2.center = CGPointMake(self.view.bounds.size.width * 0.5, self.view.bounds.size.height * 0.5 - 80);
    [mySwitch2 addTarget:self action:@selector(switchChanged:) forControlEvents:UIControlEventValueChanged];
    mySwitch2.offImage = [UIImage imageNamed:@"cross.png"];
    mySwitch2.onImage = [UIImage imageNamed:@"check.png"];
    mySwitch2.onColor = [UIColor colorWithHue:0.08f saturation:0.74f brightness:1.00f alpha:1.00f];
    mySwitch2.isRounded = NO;
    [self.view addSubview:mySwitch2];
     
    // turn the switch on with animation
    [mySwitch2 setOn:YES animated:YES];
     
    // Example of color customization
    SevenSwitch *mySwitch3 = [[SevenSwitch alloc] initWithFrame:CGRectZero];
    mySwitch3.center = CGPointMake(self.view.bounds.size.width * 0.5, self.view.bounds.size.height * 0.5 + 70);
    [mySwitch3 addTarget:self action:@selector(switchChanged:) forControlEvents:UIControlEventValueChanged];
    [self.view addSubview:mySwitch3];
     
    //self.view.backgroundColor = [UIColor colorWithRed:0.19f green:0.23f blue:0.33f alpha:1.00f];
    mySwitch3.knobColor = [UIColor colorWithRed:0.19f green:0.23f blue:0.33f alpha:1.00f];
    mySwitch3.activeColor = [UIColor colorWithRed:0.07f green:0.09f blue:0.11f alpha:1.00f];
    mySwitch3.inactiveColor = [UIColor colorWithRed:0.07f green:0.09f blue:0.11f alpha:1.00f];
    mySwitch3.onColor = [UIColor colorWithRed:0.45f green:0.58f blue:0.67f alpha:1.00f];
    mySwitch3.borderColor = [UIColor clearColor];
    mySwitch3.shadowColor = [UIColor blackColor];
}
 
- (void)switchChanged:(SevenSwitch *)sender {
    NSLog(@"Changed value to: %@", sender.on ? @"ON" : @"OFF");
}

特别说明:
☉如果服务器暂不能下载请稍后重试!总是不能下载,请联系客服QQ:597260440,谢谢合作!
☉本站所有源码仅供学习与参考,请勿用于商业用途。
模板说明:
源码-三种扁平化设计风格的UISwitch,其版权归原作者所有,如损害你的权益请联系客服QQ:597260440给予处理。

本文永久链接:http://code.fangbianle.com/goods/show-5217.html

相关源码

在线客服
热线电话

备案号:豫ICP备14017793号-2编辑热线:0371-56691758

Copyight@2014-2018 All Rights Reserved 页面加载耗时0.200秒