- CAReplicatorLayer:復(fù)制圖層
顧名思義,復(fù)制圖層就是用來(lái)復(fù)制的晚顷。它會(huì)將自己的子圖層進(jìn)行復(fù)制,連同子layer上的動(dòng)畫(huà)會(huì)一起復(fù)制峰伙。
屬性說(shuō)明:
instanceCount :復(fù)制份數(shù)。(會(huì)把原始的子圖層復(fù)制多少份该默,包括原來(lái)的一份)
instanceTransform:形變瞳氓。每一份相對(duì)上一份的形變量
instanceDelay :每一份相對(duì)上一份的延遲的時(shí)間。
修改CAReplicatorLayer的顏色通道栓袖,可以改變CAReplicatorLayer的顯示的樣式
@property float instanceRedOffset;
@property float instanceGreenOffset;
@property float instanceBlueOffset;
@property float instanceAlphaOffset;
用這個(gè)圖層匣摘,可以做顏色的漸變
屬性說(shuō)明:
colors :保存所有漸變的顏色,里面是CGColorRef裹刮,記得用id音榜,讓編譯器以為數(shù)組里面的是OC對(duì)象。
locations :保存所有漸變的位置【0-1】
startPoint:開(kāi)始漸變的點(diǎn)【0-1】
endPoint:結(jié)束漸變的點(diǎn)【0-1】
2.CAShapeLayer:形狀圖層
根據(jù)形狀捧弃,繪制內(nèi)容的圖層
屬性說(shuō)明:
path:描述形狀的路徑赠叼。默認(rèn)會(huì)把路徑封閉,然后填充。
fillColor :填充的顏色
strokeColor:描邊的顏色(如果想僅僅只描邊的話嘴办,就把fillColor設(shè)為clearcolor就好)
strokeStart:開(kāi)始描邊的比例【0-1】
strokeEnd:結(jié)束描邊的比例【0-1】
3.CAGradientLayer:漸變圖層
Do any additional setup after loading the view, typically from a nib.
復(fù)制層
CAReplicatorLayer *repL = [CAReplicatorLayer layer];
repL.frame = self.contentV.bounds;
復(fù)制5份出來(lái).
repL.instanceCount = 6;
每一個(gè)形變,都是相對(duì)于它上一個(gè)復(fù)制出來(lái)的子層開(kāi)始的.
repL.instanceTransform = CATransform3DMakeTranslation(40, 0, 0);
動(dòng)畫(huà)延時(shí)執(zhí)行.
repL.instanceDelay = 0.5;
要設(shè)置復(fù)制層的顏色,原始層的顏色要設(shè)為白色.
repL.instanceColor = [UIColor whiteColor].CGColor;
[self.contentV.layer addSublayer:repL];
添加音量震動(dòng)條
CALayer *layer = [CALayer layer];
layer.frame = CGRectMake(0, self.contentV.bounds.size.height - 150, 30, 150);
layer.backgroundColor = [UIColor redColor].CGColor;
layer.position = CGPointMake(0, self.contentV.bounds.size.height);
layer.anchorPoint = CGPointMake(0, 1);
[repL addSublayer:layer];
添加動(dòng)畫(huà).(縮放,只縮放y方向).
創(chuàng)建動(dòng)畫(huà)對(duì)象
CABasicAnimation *anim = [CABasicAnimation animation];
設(shè)置屬性值.
anim.keyPath = @"transform.scale.y";
anim.toValue = @0;
anim.repeatCount = MAXFLOAT;
anim.duration = 0.5;
anim.autoreverses = YES;
[layer addAnimation:anim forKey:nil];
效果圖:
image.png