- Create a new file CNAME and put the domain.com in the file.
- Login GoDaddy > Manage domain > DNS Zone File.
- Under A (Host) change @ point to 192.30.252.153.
- Under CName (Alias) change www point to website.github.io.
see also GitHub Pages + GoDaddy
// Create CustomView.xib, set File's Owner to CustomView. | |
// Link the top level view in the XIB to the contentView outlet. | |
class CustomView : UIView { | |
@IBOutlet private var contentView:UIView? | |
// other outlets | |
override init(frame: CGRect) { // for using CustomView in code | |
super.init(frame: frame) | |
self.commonInit() |
see also GitHub Pages + GoDaddy
//shake animation: http://stackoverflow.com/questions/27987048/shake-animation-for-uitextfield-uiview-in-swift | |
public extension UIView { | |
func shake(count : Float? = nil,for duration : TimeInterval? = nil,withTanslation translation : Float? = nil) { | |
let animation : CABasicAnimation = CABasicAnimation(keyPath: "transform.translation.x") | |
animation.timingFunction = CAMediaTimingFunction(name: kCAMediaTimingFunctionLinear) | |
animation.repeatCount = count ?? 2 | |
animation.duration = (duration ?? 0.5)/TimeInterval(animation.repeatCount) | |
animation.autoreverses = true |
// so it won't compile on a lower version. | |
extension UIAlertController { | |
func show() { | |
present(animated: true, completion: nil) | |
} | |
func present(animated animated: Bool, completion: (() -> Void)?) { | |
if let rootVC = UIApplication.sharedApplication().keyWindow?.rootViewController { | |
presentFromController(rootVC, animated: animated, completion: completion) |
extension UIViewController { | |
public var isVisible: Bool { | |
if isViewLoaded() { | |
return view.window != nil | |
} | |
return false | |
} | |
public var isTopViewController: Bool { | |
if self.navigationController != nil { |
extension UIDevice { | |
var iPhone: Bool { | |
return UIDevice().userInterfaceIdiom == .Phone | |
} | |
enum ScreenType: String { | |
case iPhone4 | |
case iPhone5 | |
case iPhone6 | |
case iPhone6Plus | |
case Unknown |
import Foundation | |
class Timer { | |
var timer = NSTimer() | |
var handler: (Int) -> () | |
let duration: Int | |
var elapsedTime: Int = 0 | |
init(duration: Int, handler: (Int) -> ()) { |
//While I'm not sure the details of your implementation, I'd probably recommend storing the start time as an NSDate(), | |
//then instead of incrementing/decrementing from an Integer/Float/Double, you can just calculate the time since the initial | |
//date, then remove that amount of time from your totalTime. That way when the app reopens, the time calculation is always | |
//correct. The calculation for determining how long ago an NSDate() is so light that it'll be nearly instantaneous. | |
import UIKit | |
class Timer { | |
private var startTime: NSDate? // Recorded when the user starts the timer. | |
private var totalTime: Double = 0.0 // If you're counting down, this is the total time designated by the user (e.g. 20 mins) |
//2 functions to pause and resume animation, I take from here and convert to Swift. | |
func pauseLayer(layer: CALayer) { | |
let pausedTime: CFTimeInterval = layer.convertTime(CACurrentMediaTime(), fromLayer: nil) | |
layer.speed = 0.0 | |
layer.timeOffset = pausedTime | |
} | |
func resumeLayer(layer: CALayer) { | |
let pausedTime: CFTimeInterval = layer.timeOffset |