let tabBarVC: TabBarController = UIApplication.shared.keyWindow?.rootViewController as! TabBarController
// 2.遍历取出所有的 tabBarButton
fortempViewintabBarVC.tabBar.subviews{
iftempView.isKind(of:NSClassFromString("UITabBarButton")!) {
//2.1 继续遍历tabBarButton 找到 UITabBarSwappableImageView 并保存
// print("tempView : \(tempView.subviews)" )
//从subviews中查找
fortempImgVintempView.subviews{
//第一种层级关系 UITabBarButton --> UITabBarSwappableImageView
iftempImgV.isKind(of:NSClassFromString("UITabBarSwappableImageView")!) {
// tabBarSwappableImageViews.append(tempImgV as! UIImageView)
print("...")
}else{
//第二种:UITabBarButton --> UIVisualEffectView --> _UIVisualEffectContentView--> UITabBarSwappableImageView
letarray = tempView.subviews[0].subviews[0].subviews
fortempImginarray {
iftempImg.isKind(of:NSClassFromString("UITabBarSwappableImageView")!) {
// tabBarSwappableImageViews.append(tempImg as! UIImageView)
print("...")
}
}
}
}
}
}