let container = CALayer()container.backgroundColor = NSColor.systemBlue.cgColorcontainer.frame = CGRect(x: 0, y: 0, width: 200, height: 200)let dimmedRoot = CALayer()let dimmedLayer1 = CALayer()dimmedLayer1.frame = CGRect(x: 20, y: 20, width: 100, height: 100)dimmedLayer1.backgroundColor = NSColor.systemGreen.cgColordimmedLayer1.transform = CATransform3DMakeRotation(0.3, 0, 0, 1)let dimmedLayer2 = CALayer()dimmedLayer2.frame = CGRect(x: 80, y: 80, width: 100, height: 100)dimmedLayer2.backgroundColor = NSColor.systemPurple.cgColordimmedLayer2.transform = CATransform3DMakeRotation(-0.1, 0, 0, 1)let dimmingLayer = CALayer()dimmingLayer.frame = CGRect(x: 0, y: 50, width: 200, height: 100)dimmingLayer.backgroundColor = NSColor(white: 0, alpha: 0.5).cgColordimmingLayer.compositingFilter = CIFilter(name: "CISourceAtopCompositing")dimmedRoot.sublayers = [ dimmedLayer1, dimmedLayer2, dimmingLayer ]container.addSublayer(dimmedRoot) 这篇关于使用具有超级图层的视图作为图层蒙版的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!
09-09 17:50