UI UIControl

//

//  RootViewController.m

//  UI 05 __ UIControl

//

//  Created by dllo on 15/12/14.

//  Copyright © 2015年 dllo. All rights reserved.

//


#import "RootViewController.h"

#import <AVFoundation/AVFoundation.h>


@interface RootViewController ()


@property(nonatomic ,retain)AVAudioPlayer *player;

@end


@implementation RootViewController


- (void)viewDidLoad {

    [super viewDidLoad];

    // Do any additional setup after loading the view.

  

    self.view.backgroundColor=[UIColor yellowColor];

    

    

    UITextField *textField=[[UITextField alloc]initWithFrame:CGRectMake(100, 100, 150, 50)];

    textField.layer.borderWidth=1;

    textField.layer.cornerRadius=10;

    [self.view addSubview:textField];

    [textField release];

    

//    添加一个触发的方法

//    监控输入状态

    

    

    [textField addTarget:self action:@selector(changeValue:) forControlEvents:UIControlEventValueChanged];

    

    

    UIStepper *steppre=[[UIStepper alloc]initWithFrame:CGRectMake(100, 240, 100, 30)];

    

    

    

    

    [self.view addSubview:steppre];

    

    [steppre release];

    

    steppre.tintColor=[UIColor  orangeColor];

    

    [steppre addTarget:self action:@selector(stepperAction:) forControlEvents:UIControlEventValueChanged];

        

//    设置最大值

    

    steppre.maximumValue=200;

//    设置最小值

    

    steppre.minimumValue=1;

    

//   设置每次修改的值

    

    steppre.stepValue=2;

    

    

//    找音乐文件路径

    NSString *path=[[NSBundle mainBundle]pathForResource:@"荒木毬菜 - 春夏秋冬 [mqms]" ofType:@"m4a"];

    

    NSURL *url=[NSURL fileURLWithPath:path];

    NSLog(@"%@",url);

    

    self.player=[[AVAudioPlayer alloc]

                 

                 initWithContentsOfURL:url error:nil];

    

    [self.player  play];

    

//

    

    

    UISlider * slidre=[[UISlider alloc]initWithFrame:CGRectMake(100, 500, 200, 50)];

    slidre.backgroundColor=[UIColor whiteColor];

    

    [self.view addSubview:slidre];

    

//    右线的颜色

    

    

    slidre.minimumTrackTintColor=[UIColor orangeColor];

    

//    线的颜色

    

    slidre.maximumTrackTintColor=[UIColor blackColor];

    

//    原点颜色

    slidre.thumbTintColor=[UIColor whiteColor];

    

    

    

    

    [slidre release];

    

    

  

    

    UISwitch *switc=[[UISwitch alloc]initWithFrame:CGRectMake(100, 400, 200, 500)];

    

    switc.backgroundColor=[UIColor orangeColor];

    [self.view addSubview:switc];

    

    switc.tintColor=[UIColor whiteColor];

    

    [switc addTarget:self action:@selector(change:) forControlEvents:UIControlEventValueChanged];

    

    

    

    [switc release];

    

    

    


}



-(void)changeValue:(UITextField *)textField{



    NSLog(@"%@",textField.text);





}




-(void)stepperAction:(UIStepper *)steppre{



    NSLog(@"%f",steppre.value);

    

    self.player.volume=steppre.value;

    

}




-(void)change:(UISwitch *)switc{



    NSLog(@"%d",switc.on);



}







- (void)didReceiveMemoryWarning {

    [super didReceiveMemoryWarning];

    // Dispose of any resources that can be recreated.

    

    

}


/*

#pragma mark - Navigation


// In a storyboard-based application, you will often want to do a little preparation before navigation

- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {

    // Get the new view controller using [segue destinationViewController].

    // Pass the selected object to the new view controller.

}

*/


@end


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值