swift - UIVisualEffectView with CAGradientLayer not working on iOS 10 -


i'm trying create effect whereby photo blurry @ top, not @ bottom, , blurriness 'fades off' gradually. achieved code below, worked fine in ios9, not in ios10.

i'm aware of known bug, described in question, prevents layer having mask , blur on same layer.

the difference between question , 1 linked, i'm not interested in using cashapelayer mask, rather cagradientlayer. i've tried fiddling adding views/masks/layers in different orders, not having luck.

    var visualeffectview = uivisualeffectview(effect: uiblureffect(style: .light))     visualeffectview.frame = cgrect(x: 0.0, y:0.0, width: photo.bounds.width, height: photo.bounds.height)     photo.addsubview(visualeffectview)      let maskstartcolour = uicolor(red: 0.0, green: 0.0, blue: 0.0, alpha: 1.0)     let maskendcolour = uicolor(red: 0.0, green: 0.0, blue: 0.0, alpha: 0.0)      let gradient = cagradientlayer()     gradient.frame = cgrect(x: 0, y: 0, width: visualeffectview.bounds.width, height: visualeffectview.bounds.height)     let colors: [anyobject] = [maskstartcolour.cgcolor, maskendcolour.cgcolor]     gradient.colors = colors     gradient.startpoint = cgpoint(x: 0.0, y: 0.0)     gradient.endpoint = cgpoint(x: 0.0, y: 1.0)       visualeffectview.layer.mask = gradient 


Comments

Popular posts from this blog

javascript - Replicate keyboard event with html button -

node.js - Node js - Trying to send POST request, but it is not loading javascript content -

javascript - Web audio api 5.1 surround example not working in firefox -