设置模糊效果并播放动画的简单方式。
简单 |
---|
![]() |
UIImageView 播放模糊动画 | UIImage 模糊效果 |
---|---|
![]() |
![]() |
将以下内容添加到您的 Podfile。
pod 'TYBlurImage'
API 文档可在 CocoaDocs - TYBlurImage 查找。
只需 #import
UIImage+BlurEffects
头文件。
调用以下方法可快速模糊。
#import <UIImage+BlurEffects.h>
...
UIImage *sourceImage = [UIImage imageNamed:@"testImage.png"];
// Light Effect
UIImage *image = [UIImage ty_imageByApplyingLightEffectToImage:sourceImage];
CGFloat blurRadius = 20.f;
CGFloat saturationDeltaFactor = 1.2f;
UIColor *tintColor = [UIColor colorWithWhite:0.4f alpha:0.3f];
UIImage *image = [UIImage ty_imageByApplyingBlurToImage:sourceImage withRadius:blurRadius tintColor:tintColor saturationDeltaFactor:saturationDeltaFactor maskImage:nil];
只需 #import
UIImageView+BlurAnimation
头文件。
UIImage *sourceImage = [UIImage imageNamed:@"testImage.png"];
UIImageView *imageView = [[UIImageView alloc] initWithImage:sourceImage];
imageView.blurTintColor = [UIColor colorWithWhite:0.4f alpha:0.3f];
imageView.blurRadius = 20;
[imageView ty_blurInAnimationWithDuration:3.0f];
使用块,您可以在图像动画完成时收到通知。
[imageView ty_blurInAnimationWithDuration:3.0f completion:^{
NSLog(@"complete");
}];
TYBlurImage
根据 MIT 许可证提供。有关更多信息,请参见 LICENSE 文件。