iOS学习笔记-082.音乐震动条
来源:互联网 发布:上海软件中心怎么样 编辑:程序博客网 时间:2024/06/01 20:39
- 音乐震动条
- 一简单分析
- 二代码
- 三图示
音乐震动条
一、简单分析
音乐震动条不需要与用户交互。我们可以使用复制层来操作。添加震动条。添加动画。
复制层说明
//创建复制层-(void)createRepl{ //复制层 CAReplicatorLayer * repL = [CAReplicatorLayer layer]; repL.frame = self.contentV.bounds; //复制6份 repL.instanceCount = 6; //形变,每一个形变都是相对于上一个复制出来的子层开始的 repL.instanceTransform = CATransform3DMakeTranslation(45, 0, 0); //动画延时执行 repL.instanceDelay = 0.5; ///要设置复制层的颜色 原始层的颜色要设为白色. repL.instanceColor = [UIColor redColor].CGColor; [self.contentV.layer addSublayer:repL]; self.repL = repL;}
二、代码
//// ViewController.m// 03_UIView75_音乐震动条//// Created by 杞文明 on 17/7/21.// Copyright © 2017年 杞文明. All rights reserved.//#import "ViewController.h"@interface ViewController ()@property (weak, nonatomic) IBOutlet UIView *contentV;@property (weak,nonatomic) CAReplicatorLayer * repL;@property (weak,nonatomic) CALayer * layer;@end@implementation ViewController- (void)viewDidLoad { [super viewDidLoad]; //1.创建复制层次 [self createRepl]; //2.添加音量震动条 [self addVoiceBar]; //3.添加动画 [self addAnimation];}//创建复制层-(void)createRepl{ //复制层 CAReplicatorLayer * repL = [CAReplicatorLayer layer]; repL.frame = self.contentV.bounds; //复制6份 repL.instanceCount = 6; //形变,每一个形变都是相对于上一个复制出来的子层开始的 repL.instanceTransform = CATransform3DMakeTranslation(45, 0, 0); //动画延时执行 repL.instanceDelay = 0.5; ///要设置复制层的颜色 原始层的颜色要设为白色. repL.instanceColor = [UIColor redColor].CGColor; [self.contentV.layer addSublayer:repL]; self.repL = repL;}//添加音量震动条-(void)addVoiceBar{ CALayer * layer = [CALayer layer]; layer.frame = CGRectMake(0, self.contentV.bounds.size.height-150, 30, 150); layer.backgroundColor = [UIColor whiteColor].CGColor; layer.position = CGPointMake(0, self.contentV.bounds.size.height); layer.anchorPoint = CGPointMake(0, 1); [self.repL addSublayer:layer]; self.layer = layer;}//添加动画-(void)addAnimation{ //添加动画 对y方向缩放 CABasicAnimation * anim = [CABasicAnimation animation]; //设置属性 anim.keyPath = @"transform.scale.y"; anim.toValue = @0; anim.repeatCount = MAXFLOAT; anim.autoreverses = YES; anim.duration = 0.5; [self.layer addAnimation:anim forKey:nil];}@end
三、图示
阅读全文
0 0
- iOS学习笔记-082.音乐震动条
- IOS学习之核心动画-音乐震动条
- ios边播放音乐边震动
- iOS学习笔记23-音效与音乐
- iOS学习笔记 音效与音乐
- iOS CAShapeLayer + UIBezierPath 实现震动条调效果
- IOS-震动
- ios 震动
- iOS 震动
- ios 震动
- iOS学习笔记之故事版和音乐播放等
- iOS动画 实现音乐振动条
- iOS开发笔记--iphone开发震动与播放声音Demo
- iOS开发笔记--iphone开发震动与播放声音Demo
- 【代码笔记】iOS-调用系统震动和声音
- iOS开发笔记--iphone开发震动与播放声音Demo
- iOS学习笔记50-IOS后台运行 之 后台播放音乐
- 短音频\音乐播放+震动(和手机来电一样震动音乐停震动停)
- ListView
- 今日头条一面笔试面试题!!!!!完整
- Jsoup之网络爬虫
- 1426 [kuangbin带你飞]专题一 简单搜索 E
- 别只关注地段、户型 楼盘隐形品质不能忽视
- iOS学习笔记-082.音乐震动条
- Codeforces Round 22 C. The Tag Game ( 搜索
- socket I/O上设置超时的三种方法及其比较
- 根据IP进行城市定位
- Xamarin Android 笔记
- jsp利用pol通过servlet来实现Excel导入数据库
- 输入输出外挂
- Java实现简单选择排序
- MySQL5.7 group by新特性,报错1055