本文介绍: iOS 置灰

//

//  UIViewOverLay.swift

//  TaxRefund

//

//  Created by dongqiangfei on 2022/12/2.

//

class UIViewOverLay: UIView {

    override init(frame: CGRect) {

        super.init(frame: frame)

    }

    

    required init?(coder aDecoder: NSCoder) {

        fatalError(“init(coder) has not been implemented“)

    }

    

    override func hitTest(_ point: CGPoint, with event: UIEvent?) -> UIView? {

        return nil

    }

}

/*  swift

let overlay = UIViewOverLay(frame: self.window!.bounds)

overlay.translatesAutoresizingMaskIntoConstraints = false

overlay.backgroundColor = .lightGray

overlay.layer.compositingFilter = “saturationBlendMode”

window?.addSubview(overlay)

*/

/*  oc

// 最顶层视图,承载滤镜,自身不接收、不拦截任何触摸事件

@interface UIViewOverLay : UIView

@end

@implementation UIViewOverLay

-(UIView*)hitTest:(CGPoint)point withEvent:(UIEvent *)event

{

     return nil;

}

@end

UIWindow *window = App的Window;

UIViewOverLay *overlay = [[UIViewOverLay alloc]initWithFrame:self.window.bounds];

overlay.translatesAutoresizingMaskIntoConstraints = false;

overlay.backgroundColor = [UIColor lightGrayColor];

overlay.layer.compositingFilter = @”saturationBlendMode“;

[window addSubview:overlay];

————————————————

*/

原文地址:https://blog.csdn.net/qq_35122556/article/details/128143375

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任

如若转载,请注明出处:http://www.7code.cn/show_29234.html

如若内容造成侵权/违法违规/事实不符,请联系代码007邮箱suwngjj01@126.com进行投诉反馈,一经查实,立即删除

发表回复

您的电子邮箱地址不会被公开。 必填项已用 * 标注