2

I need the imageView of tabBarItem to animate it while selecting. I was able to get the imageView before iOS 13 like this:

tabItem.subviews.flatMap { $0 as? UIImageView }.first

But now the subView only contains the UIVisualEffectView as its only subview and I'm not able to get the imageView of tabBarItem.

I'm using Xcode 11.1 and iOS13.1 iPhone 11.

James Z
  • 12,209
  • 10
  • 24
  • 44
Arun K
  • 810
  • 2
  • 12
  • 33

2 Answers2

2

In iOS 13, when a tab is not selected you can access UIVisualEffectView's contentView. Traverse the subviews of the contentView (UIVisualEffectView.contentView.subviews) and you should find UISwappableImageView.

When the tab is selected, you should see the UISwappableImageView as a child of UITabBarItem.

Babyak
  • 91
  • 1
  • 2
  • 2
    UISwappableImageView extends UIImageView so this works: ...(UIVisualEffectView).contentView.subviews.filter({ $0 is UIImageView }).first – ergunkocak Jan 31 '20 at 17:22
-1

You will be able to directly access the image/selectedImage property of the tabBarItem as tabBar.items![index].image and tabBar.items![index].selectedImage AFAIK.

Preson
  • 244
  • 2
  • 8
  • I need the object of imageView, not the image. My question is regarding the imageView not selected image or image – Arun K Nov 14 '19 at 14:40