I managed to make it work this way:
#define SYSTEM_VERSION_EQUAL_TO(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedSame)
#define SYSTEM_VERSION_GREATER_THAN(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedDescending)
#define SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] != NSOrderedAscending)
#define SYSTEM_VERSION_LESS_THAN(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedAscending)
#define SYSTEM_VERSION_LESS_THAN_OR_EQUAL_TO(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] != NSOrderedDescending)
UIImage *toolbarImage = [UIImage imageNamed:@"toolbarBackground"];
[self.navigationController.toolbar setBackgroundImage:toolbarImage forToolbarPosition:UIBarPositionAny barMetrics:UIBarMetricsDefault];
UIImage *searchBarImage = [UIImage imageNamed:@"searchBarBackground"];
if (SYSTEM_VERSION_LESS_THAN(@"7.0"))
[self.searchDisplayController.searchBar setBackgroundImage:searchBarImage];
else
[self.searchDisplayController.searchBar setBackgroundImage:searchBarImage forBarPosition:UIBarPositionAny barMetrics:UIBarMetricsDefault];
In the class where the customization was needed.