5 Star 9 Fork 4

LiYaoPeng / PYWaveViewTemp

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
MIT

PYWaveViewTemp

关于自定义波浪效果视图,可以当进度展示器用。(默认举行和圆形两种,可自定义形状 冲浪.gif

前言: 工作中遇到冲浪需求,于是找了很多资料做参考,最后集成了一个工具类


一、实现思路

  1. 用正弦函数,计算波浪上的点用UIBezierPathmoveToPointaddLineToPoint连接成线,
  1. 用定时器DisplayLink作为动力源
  2. 停止波浪: 停止定时器并赋值为nil
  3. 开启波浪: 新建定时器,并setNeedsDisplay

二、详细代码 1. 创建

  1. 提供的构造方法**构造方法 构造方法将自动开启冲浪不需要手动调用开启**
/**
 * 冲浪视图的类构造方法
 * @param colorMutableArray 颜色数组
 * @param progress 高度或进度,占self.frame.size.height得百分比
 */
+(instancetype)waveViewWithFrame:(CGRect)frame andColorSet: (NSMutableArray <UIColor *>*)colorMutableArray andProgress: (CGFloat)progress;
/**
 * 冲浪视图的类构造方法
 * @param colorMutableArray 颜色数组
 * @param progress 高度或进度,占self.frame.size.height得百分比
 */
-(instancetype)initWithFrame:(CGRect)frame andColorSet: (NSMutableArray <UIColor *>*)colorMutableArray andProgress: (CGFloat)progress;
  1. 默认的构方法要手动打开冲浪模式

2.开启 & 停止冲浪

是否冲浪(设置成YES开始冲浪,设置成NO停止冲浪。 默认为NO)

@property (nonatomic,assign) BOOL isWaveStart;

3.炫酷的扩展性

  1. 颜色

///需要画出的颜色数组,可以随时添加,内部在绘图的时候对数组进行了遍历

@property (nonatomic,strong) NSMutableArray<UIColor *> *colorMutableArray;
  1. 海水的高度 (可以作为下载进度)

高度或进度,占self.frame.size.height得百分比

@property (nonatomic,assign) CGFloat progress;
  1. 水波的参数

1.振幅 (水波的振幅)

@property (nonatomic, assign) CGFloat amplitude;

2.水波的周期

@property (nonatomic, assign) CGFloat cycle;

3.两个波水平之间偏移的距离

@property (nonatomic, assign) CGFloat distanceH;

4.两个波竖直之间偏移

@property (nonatomic, assign) CGFloat distanceV;

5.水波的速率(默认0.1)

@property (nonatomic, assign) CGFloat waveScale;
  1. 形状的扩展

1.自定义形状

@property (nonatomic, strong) UIBezierPath *bazierPath;

2.形状类型,默认是圆形(分为矩形和圆形两种,如果设置了bazierPath属性,则优先按照bazierPath路径获取形状)

@property (nonatomic,assign) PYWaveViewPathType pathType;

3.关于形状的枚举

typedef enum : NSUInteger {
    PYWaveViewPathType_CIRCULAR = 0,//圆形
    PYWaveViewPathType_RECT = 1,//矩形
} PYWaveViewPathType;

话不多说,源码代码请看这里

The MIT License (MIT) Copyright (c) 2017 LiYaoPeng Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

简介

关于自定义波浪效果视图,可以当进度展示器用。(默认举行和圆形两种,可自定义形状 展开 收起
Objective-C
MIT
取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
Objective-C
1
https://gitee.com/LYPLiYaoPeng/PYWaveViewTemp.git
git@gitee.com:LYPLiYaoPeng/PYWaveViewTemp.git
LYPLiYaoPeng
PYWaveViewTemp
PYWaveViewTemp
master

搜索帮助

14c37bed 8189591 565d56ea 8189591