毛玻璃效果
动态图
音频
滑块
点击条
//
// MainViewController.m
// UI05_Control
//
// Created by dllo on 15/8/4.
// Copyright (c) 2015年 zhozhicheng. All rights reserved.
//
#import "MainViewController.h"
#import <AVFoundation/AVFoundation.h>
@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
版权声明:本文为博主原创文章,未经博主允许不得转载。
原文地址:http://blog.csdn.net/cheng_xiansheng/article/details/47291203