2017-08-04 104 views

回答

1

添加效果編程繼承人的代碼片段

var darkBlur:UIBlurEffect = UIBlurEffect() 
darkBlur = UIBlurEffect(style: UIBlurEffectStyle.light) //extraLight, light, dark 
let blurView = UIVisualEffectView(effect: darkBlur) 
blurView.frame = self.view.frame //your view that have any objects 
blurView.autoresizingMask = [.flexibleWidth, .flexibleHeight] 
self.yourUIViewToBlur.addSubview(blurView) 
2

您可以在主視圖通過以下方式

@IBAction func addBlur(_ sender: Any) { 
    let blurEffect = UIBlurEffect(style: UIBlurEffectStyle.light) 
    let blurEffectView = UIVisualEffectView(effect: blurEffect) 
    blurEffectView.frame = view.bounds 
    blurEffectView.autoresizingMask = [.flexibleWidth, .flexibleHeight] 
    view.addSubview(blurEffectView) 
} 

進一步的行添加一個模糊的觀點

let blurEffect = UIBlurEffect(style: UIBlurEffectStyle.light) 

您可以添加以下效果

extraLight 
light 
dark 
regular  //10.0 or higher 
prominent //10.0 or higher 

進一步您可以使用this開源庫有更多的靈活性

相關問題