纹理(AsyncDisplayKit)图像闪光
Texture(AsyncDisplayKit) image flash
我有一个viewcontroller继承了ASDKViewController
,背景设置为图片,切换标签时图片闪烁,如何解决?
在SceneDelegate
中:
func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) {
guard let windowScene = (scene as? UIWindowScene) else { return }
window = UIWindow(frame: UIScreen.main.bounds)
window?.windowScene = windowScene
let tab = UITabBarController()
let vc1 = ViewController()
vc1.title = "vc1"
let vc2 = TestViewController()
vc2.title = "vc2"
tab.viewControllers = [vc1,vc2]
window?.rootViewController = tab
window?.makeKeyAndVisible()
}
在ViewController
中:
class ViewController: ASDKViewController<ASDisplayNode> {
override init() {
let bgImageView = ASImageNode()
bgImageView.image = UIImage(named: "backBg")
bgImageView.isUserInteractionEnabled = true
super.init(node: bgImageView)
}
required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
override func viewDidLoad() {
super.viewDidLoad()
}
好的,所以解决方案是:
let bgImageView = ASImageNode()
bgImageView.displaysAsynchronously = false
我有一个viewcontroller继承了ASDKViewController
,背景设置为图片,切换标签时图片闪烁,如何解决?
在SceneDelegate
中:
func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) {
guard let windowScene = (scene as? UIWindowScene) else { return }
window = UIWindow(frame: UIScreen.main.bounds)
window?.windowScene = windowScene
let tab = UITabBarController()
let vc1 = ViewController()
vc1.title = "vc1"
let vc2 = TestViewController()
vc2.title = "vc2"
tab.viewControllers = [vc1,vc2]
window?.rootViewController = tab
window?.makeKeyAndVisible()
}
在ViewController
中:
class ViewController: ASDKViewController<ASDisplayNode> {
override init() {
let bgImageView = ASImageNode()
bgImageView.image = UIImage(named: "backBg")
bgImageView.isUserInteractionEnabled = true
super.init(node: bgImageView)
}
required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
override func viewDidLoad() {
super.viewDidLoad()
}
好的,所以解决方案是:
let bgImageView = ASImageNode()
bgImageView.displaysAsynchronously = false