引系统的头文件
#import <AVFoundation/AVFoundation.h>
1.两条属性
@property(nonatomic,retain)UIStepper *stepper;
@property(nonatomic,retain)AVAudioPlayer *play;
2.播放
NSString *path=[[NSBundlemainBundle]pathForResource:@"盛夏光年"ofType:@"mp3"];
self.play =[[AVAudioPlayeralloc]initWithContentsOfURL:[NSURLfileURLWithPath:path]error:nil];
[self.playplay];
[self.playrelease];
//创建一个stepper
self.stepper=[[UIStepperalloc]initWithFrame:CGRectMake(100,100,100, 100)];
[self.viewaddSubview:self.stepper];
self.stepper.stepValue=2;
[self.stepperaddTarget:selfaction:@selector(stepAction:)forControlEvents:UIControlEventValueChanged];
对应的实现方法
-(void)stepAction:(UIStepper *)stepper
{
NSLog(@"%g",self.stepper.value);
//调播放音量
self.play.volume=self.stepper.value;
}