zoukankan      html  css  js  c++  java
  • iOS界面上方的纸飞飞代码(撕掉纸张留下的头)

    效果实现代码:

    - (CAShapeLayer *)tornPaperLayerWithHeight:(CGFloat)height{
        CGFloat width = MAX(CGRectGetWidth([[UIScreen mainScreen] bounds]), CGRectGetHeight([[UIScreen mainScreen] bounds]));
        CGFloat overshoot = 4;
        CGFloat maxY = height-overshoot;
        UIBezierPath *bezierPath = [UIBezierPath bezierPath];
        [bezierPath moveToPoint: CGPointMake(-overshoot, 0)];
        CGFloat x = -overshoot;
        CGFloat y = arc4random_uniform(maxY);
        [bezierPath addLineToPoint: CGPointMake(-overshoot, y)];
        while(x < width+overshoot){
            y = MAX(maxY-3, arc4random_uniform(maxY));
            x += MAX(4.5, arc4random_uniform(12.5));
            [bezierPath addLineToPoint: CGPointMake(x, y)];
        }
        y = arc4random_uniform(maxY);
        [bezierPath addLineToPoint: CGPointMake(width+overshoot, y)];
        [bezierPath addLineToPoint: CGPointMake(width+overshoot, 0)];
        [bezierPath addLineToPoint: CGPointMake(-overshoot, 0)];
        [bezierPath closePath];
    
        CAShapeLayer *shapeLayer = [CAShapeLayer layer];
        shapeLayer.fillColor = [self.paperBackgroundColor CGColor];
        shapeLayer.shadowColor = [[UIColor blackColor] CGColor];
        shapeLayer.shadowOffset = CGSizeMake(0, 0);
        shapeLayer.shadowOpacity = 0.5;
        shapeLayer.shadowRadius = 1.5;
        shapeLayer.shadowPath = [bezierPath CGPath];
        shapeLayer.path = [bezierPath CGPath];
        return shapeLayer;
    }

    使用代码:

        [self.layer addSublayer:[self tornPaperLayerWithHeight:12]];
        [self.layer addSublayer:[self tornPaperLayerWithHeight:9]];
  • 相关阅读:
    加密算法
    git 误操作
    element项目发布
    node命令
    计划
    第一次碰见类似留几手的段子手
    【vue】---猫眼项目中使用js组件的时候-------loading 加载 无法移除的原因---------
    【异步】---异步解决方案---
    【问题-方法】---buffer---解决方法,butter 文件转字符串
    【大脑】--如何让大脑快速记忆
  • 原文地址:https://www.cnblogs.com/klaus/p/3036803.html
Copyright © 2011-2022 走看看