ios - 如果对一个CALayer图层或者UIView视图中间镂空
迷茫
迷茫 2017-04-17 13:36:48
0
3
921

一个背景黑色50%透明,中间镂空一个全透明的区域该怎么弄?

迷茫
迷茫

业精于勤,荒于嬉;行成于思,毁于随。

reply all(3)
洪涛

When drawing View, use layer.mask to add a picture mask to the layer (you can make a gray and white picture, black is displayed, white is not displayed, and gray represents translucency).

大家讲道理

Wouldn’t it be nice to cover a fully transparent UIView with a translucent picture with a hollow in the middle

阿神

let path = UIBezierPath(rect:self.view.bounds)

    path.appendPath(UIBezierPath(rect: CGRect(x: 100, y: 100, width: 200, height: 300)).bezierPathByReversingPath())
    let shape = CAShapeLayer()
    
    shape.path = path.CGPath
    
    blurView.layer.mask = shape
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template