毛玻璃效果
動態圖
音頻
滑塊
點擊條
//
// MainViewController.m
// UI05_Control
//
// Created by dllo on 15/8/4.
// Copyright (c) 2015年 zhozhicheng. All rights reserved.
//
#import MainViewController.h
#import
@interface MainViewController ()
@property(nonatomic,retain)UIStepper *stepper;
@property(nonatomic,retain)AVAudioPlayer *play;
@property(nonatomic,retain)UIImageView *tomCatImageView;
@property(nonatomic,retain)NSMutableArray *picArr;
//滑塊視圖
@property(nonatomic,retain)UISlider *slider;
@end
@implementation MainViewController
-(void)dealloc
{
[_stepper release];
[_play release];
[_tomCatImageView release];
[_picArr release];
[_slider release];
[super dealloc];
}
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view.
// self.stepper=[[UIStepper alloc] initWithFrame:CGRectMake(100, 100, 100, 100)];
// [self.view addSubview:self.stepper];
// [_stepper release];
// self.stepper.stepValue=2;
// [self.stepper addTarget:self action:@selector(stepAction:) forControlEvents:UIControlEventValueChanged];
// NSString *path=[[NSBundle mainBundle] pathForResource:@李白 ofType:@mp3];
// self.play=[[AVAudioPlayer alloc] initWithContentsOfURL:[NSURL fileURLWithPath:path] error:nil];
// [self.play play];
// [_play release];
// UIImageView *imageView=[[UIImageView alloc] initWithImage:[UIImage imageNamed:@footRight_15.jpg ]];
// imageView.frame=CGRectMake(0, 0, self.view.frame.size.width, 500);
// [self.view addSubview:imageView];
// [imageView release];
//
// //先創建一個毛玻璃的效果
// UIBlurEffect *effect=[UIBlurEffect effectWithStyle:UIBlurEffectStyleLight];
// //創建一個毛玻璃視圖 ,指定效果
// UIVisualEffectView *effectView=[[UIVisualEffectView alloc] initWithEffect:effect];
// effectView.alpha=0.7;
// effectView.frame=imageView.frame;
// [imageView addSubview:effectView];
//播放gif圖
self.tomCatImageView=[[UIImageView alloc] initWithFrame:CGRectMake(100, 100, 200, 400)];
[self.view addSubview:self.tomCatImageView];
[_tomCatImageView release];
//對容器進行初始化
self.picArr =[NSMutableArray array];
for (NSInteger i =0; i<24; i++) {
//拼接圖片的名稱
// NSLog(@%02ld,i);
NSString *picName=[NSString stringWithFormat:@pie_%0.2ld.jpg,i];
// NSLog(@%@,picName);
//根據圖片名找到對應的圖片
UIImage *image=[UIImage imageNamed:picName];
//把圖片添加到數組中
[self.picArr addObject:image];
}
self.tomCatImageView.animationImages=self.picArr;
self.tomCatImageView.animationDuration=5;
self.tomCatImageView.animationRepeatCount=1000;
[self.tomCatImageView startAnimating];
self.slider = [[UISlider alloc] initWithFrame:CGRectMake(80, 500, 200, 20)];
[self.view addSubview:self.slider];
[_slider release];
//最大值 最小值
self.slider.minimumValue=0.5;
self.slider.maximumValue=5;
[self.slider addTarget:self action:@selector(sliderAction:) forControlEvents:UIControlEventValueChanged];
//
// NSArray *segmentedArray = [[NSArray alloc]initWithObjects:@1,@2,@3,@4,nil];
// UISegmentedControl *segment=[[UISegmentedControl alloc] initWithItems:segmentedArray];
// segment.frame=CGRectMake(80, 550, 200, 40);
// [self.view addSubview:segment];
// segment.layer.borderWidth=1;
// segment.selectedSegmentIndex=4;
// segment.tintColor=[UIColor blackColor];
// [segment addTarget:self action:@selector(segAction:) forControlEvents:UIControlEventValueChanged];
// [segment release];
}
//-(void)segAction:(UISegmentedControl *)seg
//{
// //按鈕默認從0開始
// NSLog(@%ld,seg.selectedSegmentIndex);
//}
-(void)sliderAction:(UISlider *)slider
{
NSLog(@%g,slider.value);
//播放時長,被slider控制
self.tomCatImageView.animationDuration= self.slider.value;
[self.tomCatImageView startAnimating];
}
//-(void)stepAction:(UIStepper *)stepper
//{
// NSLog(@%g,stepper.value);
// self.play.volume=self.stepper.value;
//
//
//
//}
- (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