内容简介: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)记得拖放到你的工程内:
以上所述就是小编给大家介绍的《Swift iOS : 模糊化》,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对 码农网 的支持!
猜你喜欢:本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们。
Music Recommendation and Discovery
Òscar Celma / Springer / 2010-9-7 / USD 49.95
With so much more music available these days, traditional ways of finding music have diminished. Today radio shows are often programmed by large corporations that create playlists drawn from a limited......一起来看看 《Music Recommendation and Discovery》 这本书的介绍吧!