自從來到簡書锻拘,開始了自己的創(chuàng)作,學(xué)會(huì)了與人分享:
分享使人快樂
自己在分享的同時(shí)也會(huì)不斷的注意到別人的分享署拟,不經(jīng)意間,就有了對(duì)比歌豺,發(fā)現(xiàn)了自己的不足,于是你就萌生了【要進(jìn)步】的想法类咧。其實(shí)當(dāng)你有了這種想法的時(shí)候,它本身就是一種進(jìn)步痕惋。可能在這之后值戳,你會(huì)有一系列的計(jì)劃(每天自學(xué)點(diǎn)xxx,每天堅(jiān)持鍛煉述寡。柿隙。鲫凶。。螟炫。),但是計(jì)劃永遠(yuǎn)只是計(jì)劃昼钻,【實(shí)踐】才是你最最需要的。
說了一通然评,好像和正題沒什么關(guān)系。-
好吧碗淌,先來看看看效果圖:
其實(shí)抖锥,非常簡單的,只要添加該方法:
/* 關(guān)鍵 */
-(void)addClickEffectForView:(UIView *)view withClickPointInSuperView:(CGPoint)point withEffectColor:(UIColor *)color removeWhenFinished:(BOOL)isRemove {
view.layer.masksToBounds = YES;
//創(chuàng)建layer
CALayer *clickEffectLayer = [CALayer layer];
CGFloat radius = sqrtf((powf(view.frame.size.width, 2) + powf(view.frame.size.height, 2)));//擴(kuò)散圓的半徑
clickEffectLayer.frame = CGRectMake(0, 0, radius * 2, radius * 2);
clickEffectLayer.cornerRadius = radius;
clickEffectLayer.position = point;
clickEffectLayer.backgroundColor = color.CGColor;
[view.layer insertSublayer:clickEffectLayer atIndex:0];//將layer放在底層
//尺寸比例動(dòng)畫
CABasicAnimation *scaleAnimation = [CABasicAnimation animationWithKeyPath:@"transform.scale.xy"];
scaleAnimation.fromValue = @0.1;//開始的大小
scaleAnimation.toValue = @1.0;//最后的大小
scaleAnimation.duration = 0.5;//動(dòng)畫持續(xù)時(shí)間
[clickEffectLayer addAnimation:scaleAnimation forKey:@"pulse"];
//完成動(dòng)畫是否移除
if (isRemove) {
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
[clickEffectLayer removeFromSuperlayer];
});
}
}
想要demo的朋友:
github:https://github.com/SeriouslyFunny/HSFColorTransitions
如果你覺得還可以的話磅废,留下你珍貴的star 荆烈, 你的支持是我前進(jìn)的最大動(dòng)力。謝謝^^