首页投稿(暂停使用,暂停投稿)买不来的iOS实用技巧

iOS核心动画高级技巧(笔记)——(五)专用图层

2016-08-18  本文已影响96人  gamper

CAShapeLayer

CATextLayer

CATransformLayer

CAGradientLayer

CAGradientLayer

CAReplicatorLayer

注意:
replicator相当于layer的父视图,默认layer超出replicator的部分也可以显示(可通过 masksToBounds设置)。

CAReplicatorLayer

使用CAReplicatorLayer并应用一个负比例变换于一个复制图层,你就可以创建指定视图(或整个视图层次)内容的镜像图片,这样就创建了一个实时的『反射』效果。

    let replicator = CAReplicatorLayer()
    replicator.frame = CGRectMake(20, 80, 100, 100)
    self.view.layer.addSublayer(replicator)
    
    replicator.instanceCount = 2
    replicator.instanceAlphaOffset = -0.5
    
    let image = UIImageView(image: UIImage(named: "face"))
    image.frame = replicator.bounds
    
    var transform = CATransform3DIdentity
    let distance = image.frame.size.height
    transform = CATransform3DTranslate(transform, 0, distance, 0)
    transform = CATransform3DScale(transform, 1, -1, 0)
    replicator.instanceTransform = transform

    replicator.addSublayer(image.layer)
反射

CAScrollLayer

CATiledLayer

CAEmitterLayer

CAEAGLLayer

AVPlayerLayer

AVPlayerLayer
上一篇下一篇

猜你喜欢

热点阅读