码迷,mamicode.com
首页 > 其他好文 > 详细

UIKit 框架之UISwitch

时间:2015-05-19 18:38:12      阅读:106      评论:0      收藏:0      [点我收藏+]

标签:

//
//  ViewController.m
//  UISwitch
//
//  Created by City--Online on 15/5/19.
//  Copyright (c) 2015年 XQB. All rights reserved.
//

#import "ViewController.h"

@interface ViewController ()
@property(nonatomic,strong) UISwitch *uiSwitch;
@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    _uiSwitch=[[UISwitch alloc]initWithFrame:CGRectMake(10, 100, 40, 20)];
    //设置打开时的TintColor颜色
    _uiSwitch.onTintColor=[UIColor redColor];
    //设置时的关闭tintColor
    _uiSwitch.tintColor=[UIColor blueColor];
    //设置滑块的颜色
    _uiSwitch.thumbTintColor=[UIColor blackColor];
//    _uiSwitch.onImage=[UIImage imageNamed:@"1.jpg"];
//    _uiSwitch.offImage=[UIImage imageNamed:@"2.jpg"];
    _uiSwitch.on=YES;
    [_uiSwitch addTarget:self action:@selector(Onchanged) forControlEvents:UIControlEventValueChanged];
    
    //改变状态
//    [_uiSwitch setOn:NO animated:YES];
    
    [self.view addSubview:_uiSwitch];

    
}
-(void)Onchanged
{
    NSLog(@"%d",_uiSwitch.on);
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end

 技术分享技术分享

UIKit 框架之UISwitch

标签:

原文地址:http://www.cnblogs.com/cuiyw/p/4515012.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!