一个 UIView,它允许手动和自动刮擦行为。
我喜欢 CocoaPods,你也会。在 .podspec 文件中添加一行 'STScratchView'。
您只需要 2 个文件
STScratchView.h
STScratchView.m
您需要创建一个 UIView(例如,子 UIView:UIImageView)并使用 -[STScratchView setHideView:(UIView *)hideView]
方法将此视图传递给 STScratchView 对象。
您还可以定义一个 UIBezierPath
,以通过 -[STScratchView setAutomaticScratchCurve:(UIBezierPath *)curvePath duration:(float)duration]
创建自动刮擦。
官方文档在此处可用:http://doc.sebastienthiebaud.us/Classes/STScratchView.html
构建并运行 Xcode 中的 STScratchViewExample 项以查看 STScratchView
的实际效果。
STScratchView *scratchView = [[STScratchView alloc] initWithFrame:CGRectMake(20.0, 60.0, 280.0, 200.0)];
[self.view addSubview:scratchView];
UIView *hideView = [[UIView alloc] initWithFrame:CGRectMake(0.0, 0.0, 280.0, 200.0)];
[hideView setBackgroundColor:[UIColor redColor]];
[scratchView setHideView:hideView];
非常简单!
Sebastien Thiebaud
STScratchView 在 MIT 许可证下提供。