我想在全屏幕中设置模糊效果,就像应用
一样这是我想要设置模糊效果的代码
let paths = NSSearchPathForDirectoriesInDomains(.DocumentDirectory, .UserDomainMask, true)[0] as String
filePathToWrite1 = "\(paths)/\(videoTitle[a]).jpg"
let img = UIImage(contentsOfFile: filePathToWrite1)
viewImg.image = img
let blurEffect = UIBlurEffect(style: UIBlurEffectStyle.Dark)
blurEffectView = UIVisualEffectView(effect: blurEffect)
blurEffectView.frame = viewImg.bounds
blurEffectView.autoresizingMask = [.FlexibleWidth, .FlexibleHeight]
viewImg.addSubview(blurEffectView)
view.addSubview(viewImg)
这是img for my Original img
模糊效果
答案 0 :(得分:0)
将此代码放在viewImg.image = img
:
viewImg.contentMode = .ScaleAspectFill