iOS的模糊化,會讓界面很炫酷,用了不能停。本案例使用了FXBlurView,對圖片進行模糊處理。javascript
使用Pod文件:java
target 'five' do
use_frameworks!
pod 'FXBlurView', '~> 1.6.4'
end複製代碼
而後執行pod install:app
pod install --verbose --no-repo-update複製代碼
以下代碼能夠直接編譯運行:ide
import UIKit
import FXBlurView
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
self.window = UIWindow();
self.window?.frame=UIScreen.main.bounds;
self.window?.makeKeyAndVisible();
self.window?.rootViewController = Page()
return true
}
}
class Page: UIViewController {
var backgroundImageView:UIImageView?
var frostedView = FXBlurView()
override func viewDidLoad() {
super.viewDidLoad()
self.backgroundImageView = UIImageView()
self.backgroundImageView!.frame = self.view.frame
self.backgroundImageView!.contentMode = .scaleToFill
view.addSubview(self.backgroundImageView!)
frostedView.underlyingView = self.backgroundImageView!
frostedView.isDynamic = true
frostedView.tintColor = UIColor.black
frostedView.frame = self.view.frame
self.view.addSubview(frostedView)
self.backgroundImageView?.image = UIImage(named: "1.jpg")
self.frostedView.updateAsynchronously(true, completion: nil)
}
}複製代碼
這是我使用的圖(文件名爲1.jpg)記得拖放到你的工程內:spa