NavigationBar bar, tint, and title text color in iOS 8

In AppDelegate.swift, in application(_:didFinishLaunchingWithOptions:) I put the following: UINavigationBar.appearance().barTintColor = UIColor(red: 234.0/255.0, green: 46.0/255.0, blue: 73.0/255.0, alpha: 1.0) UINavigationBar.appearance().tintColor = UIColor.white UINavigationBar.appearance().titleTextAttributes = [NSAttributedString.Key.foregroundColor : UIColor.white] (For Swift 4 or earlier use NSAttributedStringKey instead of NSAttributedString.Key) For titleTextAttributes, the docs say: You can specify the font, text color, text shadow color, and text shadow offset … Read more

How do I perform an auto-segue in Xcode 6 using Swift?

If your UI is laid out in a Storyboard, you can set an NSTimer in viewDidLoad of your first ViewController and then call performSegueWIthIdentifier when the timer fires: class ViewController: UIViewController { override func viewDidLoad() { super.viewDidLoad() // Do any additional setup after loading the view, typically from a nib. let timer = Timer.scheduledTimer(interval: 8.0, … Read more

Changing cell background color in UICollectionView in Swift

You can use the function collectionView with the parameter didSelectItemAtIndexPath func collectionView(collectionView: UICollectionView, didSelectItemAtIndexPath indexPath: NSIndexPath) { let selectedCell:UICollectionViewCell = myCollectionView.cellForItemAtIndexPath(indexPath)! selectedCell.contentView.backgroundColor = UIColor(red: 102/256, green: 255/256, blue: 255/256, alpha: 0.66) } This creates a constant for the selected UICollectionViewCell, then you just change the background’s color And then for return to the original color … Read more

iOS8 Safari after a pushState the :nth-child() selectors not works

Indeed nth-child doesn’t work on IOS8. Switching for nth-of-type did the trick for me. It’s well supported https://developer.mozilla.org/en-US/docs/Web/CSS/:nth-of-type That said if you want to take no chance, you can detect IOS 8 as follow. function isIOS8() { if (“600.1.4” == $.browser.version || ~navigator.userAgent.indexOf(‘OS 8_’) ){ return true; } return false; } var i=0, $el = … Read more

How do I calculate the UILabel height dynamically [duplicate]

The easiest way to get the height is sizeThatFits. Use it like this: Objective-C CGFloat maxLabelWidth = 100; CGSize neededSize = [label sizeThatFits:CGSizeMake(maxLabelWidth, CGFLOAT_MAX)]; Swift 3.0 let maxLabelWidth: CGFloat = 100 let neededSize = label.sizeThatFits(CGSize(width: maxLabelWidth, height: CGFloat.greatestFiniteMagnitude)) The height your label needs is neededSize.height. Note that im using CGFLOAT_MAX for the size height, to … Read more

Implement CLLocationManagerDelegate methods in Swift

You need to add the NSLocationAlwaysUsageDescription or NSLocationWhenInUseUsageDescription key to your plist if you haven’t already, they are now mandatory, iOS8+ requires one of these two strings to be set to use locations. Which one you use depends on how you intend ask for the location. Use NSLocationAlwaysUsageDescription for apps that want to use the … Read more