zoukankan      html  css  js  c++  java
  • UI2_UISwitch与UIActivity

    //
    //  ViewController.m
    //  UI2_UISwitch与UIActivity
    //
    //  Created by zhangxueming on 15/7/7.
    //  Copyright (c) 2015年 zhangxueming. All rights reserved.
    //
    
    #import "ViewController.h"
    
    @interface ViewController ()
    
    @end
    
    @implementation ViewController
    
    - (void)viewDidLoad {
        [super viewDidLoad];
        // Do any additional setup after loading the view, typically from a nib.
        //开关的尺寸固定大小(51*31)
        UISwitch *sw = [[UISwitch alloc] initWithFrame:CGRectMake(100, 200, 0, 0)];
        NSLog(@"sw = %@", sw);
        sw.thumbTintColor = [UIColor redColor];
        sw.tintColor = [UIColor blueColor];
        sw.onTintColor = [UIColor yellowColor];
        [sw addTarget:self action:@selector(swichValueChanged:) forControlEvents:UIControlEventValueChanged];
        //动画打开开关
        [sw setOn:YES animated:YES];
        [self.view addSubview:sw];
        
        
        //活动指示器
        UIActivityIndicatorView * indicatorView = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge];
        [self.view addSubview:indicatorView];
        indicatorView.center = self.view.center;
        [indicatorView startAnimating];
        indicatorView.tag =100;
        self.view.backgroundColor = [UIColor blackColor];
    }
    
    - (void)swichValueChanged:(UISwitch *)sw
    {
        NSLog(@"sw value = %i", sw.on);
        UIActivityIndicatorView *indicator = (UIActivityIndicatorView *)[self.view viewWithTag:100];
        if (sw.isOn) {
            [indicator startAnimating];
        }
        else{
            [indicator stopAnimating];
        }
    }
    
    - (void)didReceiveMemoryWarning {
        [super didReceiveMemoryWarning];
        // Dispose of any resources that can be recreated.
    }
    
    @end
    
  • 相关阅读:
    Java语言
    包名规范
    带参数的方法
    成员变量和局部变量
    Java数据类型
    java反射机制
    JDK安装
    注释
    二维数组
    数组的经典排序
  • 原文地址:https://www.cnblogs.com/0515offer/p/4638784.html
Copyright © 2011-2022 走看看