码迷,mamicode.com
首页 > 其他好文 > 详细

CA*Layer(CAReplicatorLayer--)

时间:2016-05-13 07:46:10      阅读:126      评论:0      收藏:0      [点我收藏+]

标签:

CAReplicatorLayer

(反射应用)

指定一个继承于UIView的ReflectionView,它会自动产生内容的反射效果:

+ (Class)layerClass//我们也可以通过重写View中的该方法来使其创建我们需要的layer类
{
    return [CAReplicatorLayer class];
}
- (void)setUp
{
    //configure replicator
    CAReplicatorLayer *layer = (CAReplicatorLayer *)self.layer;
    layer.instanceCount = 2;
    //move reflection instance below original and flip vertically
    CATransform3D transform = CATransform3DIdentity;
    CGFloat verticalOffset = self.bounds.size.height + 2;
    transform = CATransform3DTranslate(transform, 0, verticalOffset, 0);
    transform = CATransform3DScale(transform, 1, -1, 0);
    layer.instanceTransform = transform;
    //reduce alpha of reflection layer
    layer.instanceAlphaOffset = -0.6;
}

- (id)initWithFrame:(CGRect)frame
{
    //this is called when view is created in code
    if ((self = [super initWithFrame:frame])) {
        [self setUp];
    }
    return self;
}
- (void)awakeFromNib
{
    //this is called when view is created from a nib
    [self setUp];
}

技术分享

CA*Layer(CAReplicatorLayer--)

标签:

原文地址:http://www.cnblogs.com/jingdizhiwa/p/5484750.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!