Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>This code is basically determining what the iOS is and selecting the correct method call to set the <code>tintColor</code> of the navigationBar. See comments in code below </p> <pre><code>/* This is basically getting the systemVersion of the device so 7.0.1 - as this is returned as an NSString the user is separating this string based on the string "." which will place each string into the array. so you will have 3 objects in this array of "7", "0", "1" */ NSArray *ver = [[UIDevice currentDevice].systemVersion componentsSeparatedByString:@"."]; /* Once we have separated this string into the array we are getting the first object in that array so index `0` which will return a string at which point we are converting the string "7" to an intValue and comparing it to the int 7. So if that value is 7 or greater return TRUE */ if ([[ver objectAtIndex:0] intValue] &gt;= 7) { /* The value was TRUE so lets use the iOS 7 way of setting the tintColor. We do this by setting barTintColor for the navigationBar and because in iOS 7 the navigationBar can be translucent - by default this is YES but because we are setting to a color we want we need to set this to NO because we don't want to have it translucent. */ self.navigationController.navigationBar.barTintColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"top_bar"]]; self.navigationController.navigationBar.translucent = NO; } else { /* If all fails in the if statements conditional check we must be on something that is below iOS 7 so use the old way of things and just set the tintColor */ self.navigationController.navigationBar.tintColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"top_bar"]]; } </code></pre> <p>Just so you know this doesn't work. If you are going to use this change it to:</p> <pre><code>if (floor(NSFoundationVersionNumber) =&gt; NSFoundationVersionNumber_iOS_7_0) { self.navigationController.navigationBar.barTintColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"top_bar"]]; self.navigationController.navigationBar.translucent = NO; } else { self.navigationController.navigationBar.tintColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"top_bar"]]; } </code></pre> <p>this is because <code>if ([[ver objectAtIndex:0] intValue] &gt;= 7)</code> will return FALSE even if iOS 7.</p> <p>To set the toolbar you could use the same method but replace:</p> <pre><code>self.navigationController.navigationBar.barTintColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"top_bar"]]; self.navigationController.navigationBar.translucent = NO; </code></pre> <p>with</p> <pre><code>[toolbar setBarTintColor:[UIColor colorWithPatternImage:[UIImage imageNamed:@"dropdownbar"]]]; [toolbar setTranslucent:NO]; </code></pre> <p>and replace </p> <pre><code> self.navigationController.navigationBar.tintColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"top_bar"]]; </code></pre> <p>with</p> <pre><code> [toolbar setTintColor:[UIColor colorWithPatternImage:[UIImage imageNamed:@"dropdownbar"]]]; </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload