中文字幕一区二区人妻电影,亚洲av无码一区二区乱子伦as ,亚洲精品无码永久在线观看,亚洲成aⅴ人片久青草影院按摩,亚洲黑人巨大videos

iOS開(kāi)關(guān)(Switches)

IOS開(kāi)關(guān)的使用

開(kāi)關(guān)用于打開(kāi)和關(guān)閉狀態(tài)之間的切換。

重要的屬性

  • onImage
  • offImage
  • on

重要的方法

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

添加自定義方法 addSwitch 和開(kāi)關(guān)

-(IBAction)switched:(id)sender{
    NSLog(@"Switch current state %@", mySwitch.on ? @"On" : @"Off");
}
-(void)addSwitch{
    mySwitch = [[UISwitch alloc] init];
    [self.view addSubview:mySwitch];
    mySwitch.center = CGPointMake(150, 200);
    [mySwitch addTarget:self action:@selector(switched:)
    forControlEvents:UIControlEventValueChanged];    
}

在 ViewController.m 中修改 viewDidLoad,如下所示

(void)viewDidLoad
{
   [super viewDidLoad];
   [self addSwitch];
}

輸出

現(xiàn)在當(dāng)我們運(yùn)行該應(yīng)用程序我們會(huì)看到下面的輸出

switchOutput1

向右滑動(dòng)開(kāi)關(guān)輸出如下所示

switchOutput2

其他擴(kuò)展