{"id":18880826,"url":"https://github.com/keenteam1990/ktwaveview","last_synced_at":"2026-02-20T20:30:19.670Z","repository":{"id":107584489,"uuid":"102427861","full_name":"KeenTeam1990/KTWaveView","owner":"KeenTeam1990","description":"🐳 一个渐变水波波浪视图","archived":false,"fork":false,"pushed_at":"2017-09-05T03:21:34.000Z","size":133,"stargazers_count":4,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-12-31T03:23:21.624Z","etag":null,"topics":["objective-c","waves"],"latest_commit_sha":null,"homepage":"","language":"Objective-C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/KeenTeam1990.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-09-05T03:08:44.000Z","updated_at":"2024-09-13T09:08:56.000Z","dependencies_parsed_at":"2023-06-08T13:31:01.531Z","dependency_job_id":null,"html_url":"https://github.com/KeenTeam1990/KTWaveView","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KeenTeam1990%2FKTWaveView","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KeenTeam1990%2FKTWaveView/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KeenTeam1990%2FKTWaveView/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KeenTeam1990%2FKTWaveView/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/KeenTeam1990","download_url":"https://codeload.github.com/KeenTeam1990/KTWaveView/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239848049,"owners_count":19707076,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["objective-c","waves"],"created_at":"2024-11-08T06:46:09.782Z","updated_at":"2026-02-20T20:30:19.608Z","avatar_url":"https://github.com/KeenTeam1990.png","language":"Objective-C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# KTWaveView\n\n\u003e一个渐变水波视图，水波视图相信大家已经司空见惯，但是最近视觉要求绘制一个波浪是渐变色的，且背景是径向渐变的水波，于是在原来的基础上做了相应改进。\n\n**先来看下效果图：**\n\n![image](https://github.com/KeenTeam1990/KTWaveView/blob/master/Pic/KTWaveView.png)\n\n\n**基本实现以下功能：**\n\n- 支持自定义水波形状\n- 支持自定义背景渐变\n- 支持自定义两层水波独立渐变色\n- 支持波纹周期、速度、振幅等自定义\n·····\n\nDemo见github [KTWaveView](https://github.com/KeenTeam1990/KTWaveView.git)，喜欢的话请star下^_^\n### 使用说明\n\n KTWaveView 目前已经支持CocoaPods，可以在很短的时间内被添加到任何工程中。\n\n#### 安装\n KTWaveView 的安装，最简单的方法是使用CocoaPods，在PodFile里添加如下：\n```\npod 'KTWaveView', '~\u003e 0.0.1'\n```\n或者直接将```KTWaveView.h```和```KTWaveView.m```两个源文件直接拖进自己的项目工程中。\n\n#### 集成\n* 首先导入头文件\n```\n#import \"KTWaveView.h\"\n```\n* 遵循相应协议\n```\n@interface ViewController () \u003cKTWaveViewDelegate\u003e {\n    KTWaveView *_wave;\n    KTWaveView *_rectWave;\n}\n```\n* 初始化\n```\nNSArray *colors = @[(__bridge id)[UIColor colorWithRed:134/255.0 green:208/255.0 blue:248/255.0 alpha:0.75].CGColor, (__bridge id)[UIColor whiteColor].CGColor];  //里\nNSArray *sColors = @[(__bridge id)[UIColor colorWithRed:166/255.0 green:240/255.0 blue:255/255.0 alpha:0.5].CGColor, (__bridge id)[UIColor colorWithRed:240/255.0 green:250/255.0 blue:255/255.0 alpha:0.5].CGColor];  //外\n\n    \n    //默认圆形波浪\n    CGFloat waveWidth = 160;\n    _wave = [[KTWaveView alloc]initWithFrame:CGRectMake(100, 100, waveWidth, waveWidth)];\n    [self.view addSubview:_wave];\n    _wave.layer.cornerRadius = waveWidth/2;\n    _wave.clipsToBounds = YES;\n    _wave.colors = colors;\n    _wave.sColors = sColors;\n    _wave.percent = 0.7;\n   \n    //方形波浪\n    _rectWave = [[KTWaveView alloc]initWithFrame:CGRectMake(200, 560, 140, 100)];\n    [self.view addSubview:_rectWave];\n    _rectWave.colors = colors;\n    _rectWave.sColors = sColors;\n    _rectWave.percent = 0.7;\n    _rectWave.delegate = self;\n```\n* 开始绘制\n```\n [_wave startWave];\n [_rectWave startWave];\n```\n* 实现相应协议\n```\n//自定义背景渐变\n- (void)drawBgGradient:(KTWaveView *)waveView context:(CGContextRef)context {\n    CGColorSpaceRef colorSpace=CGColorSpaceCreateDeviceRGB();\n    CGFloat compoents[8]={\n        1.0,1.0,1.0,1.0,\n        166/255.0,240/255.0,255.0/255.0,1\n    };\n    \n    CGFloat locations[2]={0,0.7};\n    CGGradientRef gradient= CGGradientCreateWithColorComponents(colorSpace, compoents, locations, 2);\n    \n    CGFloat width = CGRectGetWidth(waveView.frame);\n    CGFloat height = CGRectGetHeight(waveView.frame);\n    CGPoint center = CGPointMake(width/2, height/2);\n    \n    if (waveView == _rectWave) {\n        //线性渐变\n        CGContextDrawLinearGradient(context, gradient, CGPointMake(0, 0), CGPointMake(width, height), kCGGradientDrawsAfterEndLocation);\n    } else {\n        //径向渐变\n        CGContextDrawRadialGradient(context, gradient, center,0, center, width/2, kCGGradientDrawsAfterEndLocation);\n    }\n    \n    CGColorSpaceRelease(colorSpace);\n    CGGradientRelease(gradient);\n}\n```\n\n完成上述步骤，渐变水波已经集成到我们的项目中了，当然KTWaveView还提供了一系列的对外属性变量，使我们可以高度自定义水波，如下：\n\n```\n@property (nonatomic, assign) CGFloat percent;           // 百分比      默认:0\n@property (nonatomic, assign) CGFloat waveAmplitude;     // 波纹振幅     默认:0\n@property (nonatomic, assign) CGFloat waveCycle;         // 波纹周期     默认:1.29 * M_PI / self.frame.size.width\n@property (nonatomic, assign) CGFloat waveSpeed;         // 波纹速度     默认:0.2/M_PI\n@property (nonatomic, assign) CGFloat waveGrowth;        // 波纹上升速度  默认:1.00\n@property (nonatomic, assign) BOOL isRound;              // 圆形/方形    默认:YES\n\n@property (nonatomic, strong) NSArray *colors;   // 渐变的颜色数组1\n@property (nonatomic, strong) NSArray *sColors;  // 渐变的颜色数组2\n····\n```\n\n另外还提供了相关API控制水波\n```\n// 开始波浪\n- (void)startWave;\n// 停止波动\n- (void)stopWave;\n// 继续波动\n- (void)goOnWave;\n// 清空波浪\n- (void)reset;\n```\n等等一系列，具体可参考```KTWaveView.h``\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkeenteam1990%2Fktwaveview","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkeenteam1990%2Fktwaveview","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkeenteam1990%2Fktwaveview/lists"}