这是一个基于 Facebook Slingshot 应用启发的像素动画的自定义 UIView
子类。
有两种选择
CocoaPods
platform :ios
pod 'CRPixellatedView'
...
pod install
以安装依赖项。源文件
要使用 CRCutoutView,创建一个 CRCutoutView
,配置并动画化!
CRCutoutView 制作示例
CRPixellatedView *pixellatedView = [[CRPixellatedView alloc] initWithFrame:CGRectMake(0, 0, 320, 320)];
pixellatedView.image = [UIImage imageNamed:@"Image"];
[self.view addSubview:pixellatedView]; // Add to your view
[pixellatedView animate];
您可以配置此可定制的示例设置
CRPixellatedView *pixellatedView = [[CRPixellatedView alloc] initWithFrame:CGRectMake(0, 0, 320, 320)];
pixellatedView.image = [UIImage imageNamed:@"Image"];
pixellatedView.pixelScale = 20.0f;
pixellatedView.animationDuration = 0.8f;
[self.view addSubview:pixellatedView]; // Add to your view
[pixellatedView animateWithCompletion:^(BOOL finished) {
NSLog(@"completed");
}];
此外,您还可以通过使用 reverse
属性自定义动画效果
CRPixellatedView *pixellatedView = [[CRPixellatedView alloc] initWithFrame:CGRectMake(0, 0, 320, 320)];
pixellatedView.image = [UIImage imageNamed:@"Image"];
pixellatedView.pixelScale = 20.0f;
pixellatedView.animationDuration = 0.8f;
pixellatedView.reverse = YES; // Reverse effect
[self.view addSubview:pixellatedView]; // Add to your view
[pixellatedView animateWithCompletion:^(BOOL finished) {
NSLog(@"completed");
}];
pixellatedView.reverse = YES; // Reverse effect
pixellatedView.reverse = NO; // (default)
pixellatedView.pixelScale = 30.0f;
请参阅 CRPixelledViewDemo Xcode 项目。
欢迎任何想要为项目贡献力量的人。
CRCutoutView 在 MIT 许可下发布。请参阅 LICENSE。
Christian Roman