Skip to content

Instantly share code, notes, and snippets.

View garymansted's full-sized avatar
💭
Jesus is the key

Gary Mansted garymansted

💭
Jesus is the key
View GitHub Profile
@garymansted
garymansted / CheckDeviceMotion.swift
Created August 26, 2016 09:46
Check devices motions -> pitch, roll and yaw SWIFT
import CoreMotion // Import CoreMotion (header)
// Class vars
var pitch = 0.0
var attitude: CMAttitude?
var roll = 0.0
var yaw = 0.0
let motionManager = CMMotionManager() // Create motionManager instance
@garymansted
garymansted / ChangeNavBarTitleTextAttributes.swift
Last active August 4, 2016 09:39
Change navigation bar title text font attributes in code SWIFT
//Set up in viewDidLoad()
let attributes = [NSForegroundColorAttributeName : UIColor.whiteColor(), NSFontAttributeName : UIFont(name: "HelveticaNeue-Light", size: 24)!]
//Set the navigation bar attributes
self.navigationController?.navigationBar.titleTextAttributes = attributes
self.navigationController?.navigationBar.translucent = false
self.navigationController?.navigationBar.barTintColor = UIColor.blackColor()
self.navigationController?.title = "Hello World!"
@garymansted
garymansted / TwoBarButtonsOnOneSide.swift
Last active August 6, 2016 07:16
Add two bar button items on the one side with images SWIFT
//Create button objects
var barButton1 = UIBarButtonItem()
var barButton2 = UIBarButtonItem()
//Create button instances and images in viewDidLoad()
let image1 = UIImage(named: "HelloWorldImage1")!
let image2 = UIImage(named: "HelloWorldImage2")!
barButton1 = UIBarButtonItem(image: image1, style: UIBarButtonItemStyle.Plain, target: self, action: #selector(ExampleVC.function1))
barButton2 = UIBarButtonItem(image: image2, style: UIBarButtonItemStyle.Plain, target: self, action: #selector(ExampleVC.function2))