CA*Layer(CAReplicatorLayer--)

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--)

上一篇:(原创)VM中的CentOS6.4中安装CloudStack6.3①


下一篇:[CQOI2009] 中位数