• [翻译] CRPixellatedView-用CIPixellate滤镜动态渲染UIView


    CRPixellatedView-用CIPixellate滤镜动态渲染UIView

    https://github.com/chroman/CRPixellatedView

    本人测试的效果:

    Usage

    To use CRPixellatedView, create a CRPixellatedView, configure and animate!

    要使用CRPixellatedView的话,创建一个CRPixellatedView,配置以及做动画!

    An example of making a CRPixellatedView:

    以下是一个使用CRPixellatedView的例子:

    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];
    

    You can configure this settings, customizable example:

    以下是配置设置,自定义的例子:

    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");
    }];
    

    Also, you can customize the animation effect using the reverse property:

    以下是你使用反转效果的例子:

    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");
    }];
    

    Examples

    pixellatedView.reverse = YES; // Reverse effect
    

    pixellatedView.reverse = NO; // (default)
    pixellatedView.pixelScale = 30.0f;

    核心的地方:

    使用了3个CoreImage的滤镜用来重绘View:)

  • 相关阅读:
    windows7环境下使用pip安装MySQLdb
    ZeroMQ
    LazyValue<T>
    方法执行失败,重复执行指定次数某个方法
    关于截取字符串substr和substring两者的区别
    C#的字符串优化-String.Intern、IsInterned
    几张图轻松理解String.intern()
    string 线程安全
    请问C#中string是值传递还是引用传递?
    C# String与StringBuilder
  • 原文地址:https://www.cnblogs.com/YouXianMing/p/3877808.html
Copyright © 2020-2023  润新知