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

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

迷茫
迷茫

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

répondre à tous(3)
洪涛

绘制View的时候用layer.mask给layer加个图片蒙版(可以做一张灰白图片,黑色显示,白色不显示,灰色代表半透明)。

大家讲道理

全透明的UIView上盖一层半透明的中间镂空的图片不就好了

阿神

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
Derniers téléchargements
Plus>
effets Web
Code source du site Web
Matériel du site Web
Modèle frontal
À propos de nous Clause de non-responsabilité Sitemap
Site Web PHP chinois:Formation PHP en ligne sur le bien-être public,Aidez les apprenants PHP à grandir rapidement!