HTML5   发布时间:2022-04-27  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了ios – 在Objective C中,我们如何以圆形/圆形形状模糊脸部?大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
我在iOS应用程序上工作,我从图像和模糊的脸检测脸,我已经实现了矩形的模糊面,但我需要的是模糊圆形的脸.我试过的是

-(void)markAfterFaceDetect:(NSArray *)features
{

    for (CIFaceFeature *f in features)
    {

        CGRect aRect = f.bounds;

        NSLog(@"here is the height of h %f",aRect.size.height);

        // aRect.size.height=aRect.size.height+10;

        aRect.origin.y = self.viewShow.bounds.size.height - aRect.size.height - aRect.origin.y;



        NSLog(@"Height Of the Image Is : == %f",_imageView.image.size.height);
        //self.bounds.size

        rectFaceDetect = aRect;



        UIVisualEffect *blurEffect;
        blurEffect = [UIBlurEffect effectWithStyle:UIBlurEffectStyleLight];

        UIVisualEffectView *visualEffectView;
        visualEffectView = [[UIVisualEffectView alloc] initWithEffect:blurEffect];

        visualEffectView.frame = vv.frame;

        //visualEffectView.layer.cornerRadius = visualEffectView.frame.size.height/2;

        visualEffectView.alpha =0.96;

        visualEffectView.tag = markViewTag;
        // [self.imageView addSubview:visualEffectView];


        CAShapeLayer *mask = [CAShapeLayer layer];
        mask.path = [UIBezierPath bezierPathWithOvalInRect:visualEffectView.bounds].CGPath;
        visualEffectView.layer.mask = mask;
    }
}

使用这种方式我已经设法模糊圆形或圆形的脸,但当我拍摄视图的屏幕截图以保存应用程序数据库中的模糊图像时,其Alpha变为0并且模糊区域变得可见,我用于截取屏幕截图的代码

CGRect rect = viewShow.frame;
UIGraphicsBeginImageContext(rect.sizE);
CGContextRef context = UIGraphicsGetCurrentContext();
[viewShow.layer renderInContext:context];
UIImage *img = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();

这是截图前后的图像

Now i have used this Category and Achieved this Blur in Rectangular form Image is Attached

现在我有两个问题.
1-如何仅将脸部模糊成圆形或圆形?
2-当我以编程方式截取屏幕时,为什么Alpha变为0.

期望的模糊将如下所示

我们将非常感谢您的帮助.

解决方法

使用 drawViewHierarchyInRect:afterScreenUpdates:捕获视图层次结构的屏幕外观.

大佬总结

以上是大佬教程为你收集整理的ios – 在Objective C中,我们如何以圆形/圆形形状模糊脸部?全部内容,希望文章能够帮你解决ios – 在Objective C中,我们如何以圆形/圆形形状模糊脸部?所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。