Default tab bar item colors using swift Xcode 6

Each (default) tab bar item consists of text and icon. It is pretty easy to change the text colors globally by specifying the appearance: // you can add this code to you AppDelegate application:didFinishLaunchingWithOptions: // or add it to viewDidLoad method of your TabBarController class UITabBarItem.appearance().setTitleTextAttributes([NSForegroundColorAttributeName: UIColor.magentaColor()], forState:.Normal) UITabBarItem.appearance().setTitleTextAttributes([NSForegroundColorAttributeName: UIColor.redColor()], forState:.Selected) With images situation is … Read more

How can I programmatically find Swift’s version?

You can use conditional compilation directives to test for the specific Swift version used to build your project: #if swift(>=5.0) print(“Hello, Swift 5!”) #elseif swift(>=4.0) print(“Hello, Swift 4!”) #elseif swift(>=3.0) print(“Hello, Swift 3!”) #elseif swift(>=2.2) print(“Hello, Swift 2.2!”) #elseif swift(>=2.1) print(“Hello, Swift 2.1!”) #endif

iOS Segue – Left to Right –

This is how I achieve the effect without requiring a nav-controller. Try this instead: Swift 4: import UIKit class SegueFromLeft: UIStoryboardSegue { override func perform() { let src = self.source let dst = self.destination src.view.superview?.insertSubview(dst.view, aboveSubview: src.view) dst.view.transform = CGAffineTransform(translationX: -src.view.frame.size.width, y: 0) UIView.animate(withDuration: 0.25, delay: 0.0, options: .curveEaseInOut, animations: { dst.view.transform = CGAffineTransform(translationX: 0, … Read more

Implementing HMAC and SHA1 encryption in swift

Problem solved! First off i wasn’t using the string function properly… I ended up with this: let hmacResult:String = “myStringToHMAC”.hmac(HMACAlgorithm.SHA1, key: “myKey”) Then I had forgotten I needed to base64 encode the hmac result. So i modified the string function linked in my question to… enum HMACAlgorithm { case MD5, SHA1, SHA224, SHA256, SHA384, SHA512 … Read more