Created
June 27, 2017 07:16
-
-
Save 5ZSQ/18f0b3b17f42d96fecb82c51bc056740 to your computer and use it in GitHub Desktop.
iOS - 使用Core Animation中的CATranstion实现背景自然渐变
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
NSString *imgUrl = _dataArray[index][@"url"]; //下一张背景图url | |
UIImage *placeHolder = _baseImgView.image; //使用上一张背景图作为placeholder | |
[_baseImgView sd_setImageWithURL:[NSURL URLWithString:imgUrl] placeholderImage:placeHolder completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, NSURL *imageURL) { | |
if (image) | |
CATransition *transition = [CATransition animation]; | |
transition.type = kCATransitionFade; | |
transition.duration = 1.0f; | |
transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]; | |
[_baseImgView.layer addAnimation:transition forKey:nil]; | |
_baseImgView.image = [[image blurImage] jy_lucidImage]; | |
} | |
}]; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment