UIImage+ImageEffects的category 模糊效果

本文介绍了一种在 iOS 应用中实现图片模糊效果的方法。通过使用 UIImage+ImageEffects 扩展,演示了如何创建全图模糊、部分区域模糊及调整模糊程度等不同效果,并提供了具体的代码实例。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

#import "ViewController.h"
#import "UIImage+ImageEffects.h"
@interface ViewController ()

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    //源码地址 https://github.com/YouXianMing/UIImageBlur
    
    //原始图片  634*1102
    UIImage *sourceImage = [UIImage imageNamed:@"normal"];
    //对图片进行模糊
    //1.全图模糊
    //UIImage *blurImage = [sourceImage blurImage];
    //2.部分模糊
    //UIImage *blurImage = [sourceImage blurImageAtFrame:CGRectMake(0, 200, sourceImage.size.width, sourceImage.size.height/2)];
    //3.模糊程度效果
    UIImage *blurImage = [sourceImage blurImageWithRadius:10];
    //加载图片
    UIImageView *imageView = [[UIImageView alloc]initWithImage:blurImage];
    imageView.frame = self.view.bounds;
    [self.view addSubview:imageView];
}
@end


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值