I am using swift to make an IOS application. I have a UIToolBar
in my application and I need to change its background. I use the following code in Objective-C to do that:
[topBar setBackgroundImage:[UIImage imageNamed:@"header_bg.png"] forToolbarPosition:UIToolbarPositionAny barMetrics:UIBarMetricsDefault];
Now when I rewrote the code in swift it looks like this:
topBar.setBackgroundImage(UIImage(named:"header_bg.png"), forToolbarPosition: UIToolbarPositionAny, barMetrics: UIBarMetricsDefault)
And this showed the errors that Use of unresolved type UIBarMetricsDefault
and Use of unresolved type UIToolbarPositionAny
. So I did a search and found this documentation. According to the documentation I changed the code like this:
topBar.setBackgroundImage(UIImage(named:"header_bg.png"), forToolbarPosition: Any, barMetrics: Default)
But it still shows the same error. Anyone got any idea what is wrong here?