内容简介:Swift iOS : 模糊化
iOS的模糊化,会让界面很炫酷,用了不能停。本案例使用了FXBlurView,对图片进行模糊处理。
使用Pod文件:
target 'five' do use_frameworks! pod 'FXBlurView', '~> 1.6.4' end
然后执行pod install:
pod install --verbose --no-repo-update
如下代码可以直接编译运行:
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)记得拖放到你的工程内:
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持 码农网
猜你喜欢:本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们。
Web 2.0 Heroes
Bradley L. Jones / Wiley / 2008-04-14 / USD 24.99
Web 2.0 may be an elusive concept, but one thing is certain: using the Web as merely a means of retrieving and displaying information is history. Today?s Web is immediate, interactive, innovative. It ......一起来看看 《Web 2.0 Heroes》 这本书的介绍吧!