This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import UIKit | |
@IBDesignable | |
class CustomView: UIView { | |
@IBInspectable var borderColor: UIColor? = UIColor.clearColor() { | |
didSet { | |
layer.borderColor = self.borderColor?.CGColor | |
} | |
} | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import UIKit | |
@objc(DismissSegue) | |
class DismissSegue: UIStoryboardSegue { | |
override func perform() { | |
if let controller = sourceViewController.presentingViewController { | |
controller.dismissViewControllerAnimated(true, completion: nil) | |
} | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import UIKit | |
@IBDesignable | |
class CustomImageView: UIImageView { | |
@IBInspectable var borderColor: UIColor? = UIColor.clearColor() { | |
didSet { | |
layer.borderColor = self.borderColor?.CGColor | |
} | |
} | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import GameplayKit | |
// MARK: | |
extension Int { | |
// Make this a static function for Int | |
static func randomRange(range: Int) -> Int { | |
return GKRandomSource.sharedRandom().nextIntWithUpperBound(range) | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
print("Last Page Said Done") | |
if let appVC = storyboard?.instantiateViewControllerWithIdentifier("YourAppViewControler") { | |
let currentVC = pageViewController | |
appVC.view.frame = currentVC.view.frame | |
appVC.willMoveToParentViewController(nil) | |
addChildViewController(appVC) | |
transitionFromViewController(currentVC, toViewController: appVC, duration: 1.0, options: .TransitionCrossDissolve, animations: { () -> Void in | |
// |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func loadDataFromPlist(plist: String) -> NSArray? { | |
if let path = NSBundle.mainBundle().pathForResource(plist, ofType: "plist") { | |
return NSArray(contentsOfFile: path) | |
} | |
return nil | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Somewhere inside cellForRowAtIndexPath | |
// You could use this to color every other cell | |
// Use % 2 to find each odd numbered cell | |
if indexPath.row % 2 == 0 { | |
cell.backgroundColor = UIColor(hue: 0.43, saturation: 1.0, brightness: 0.75, alpha: 1.0) | |
} else { | |
cell.backgroundColor = UIColor(hue: 0.43, saturation: 1.0, brightness: 0.85, alpha: 1.0) | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Somewhere inside of cellForRowAtIndexPath | |
// Or, set the brightness. Here the min value is 0.55 and max value is 1.0 (0.45 + 0.55) | |
let b = 0.45 / CGFloat(array.count) * CGFloat(indexPath.row) + 0.55 | |
cell.backgroundColor = UIColor(hue: 0.5, saturation: 1.0, brightness: b, alpha: 1.0) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Somwhere inside of cellForRowAtIndexPath | |
// Color cells by changing hue | |
let hue = 1 / CGFloat(array.count) * CGFloat(indexPath.row) | |
cell.backgroundColor = UIColor(hue: hue, saturation: 1.0, brightness: 1.0, alpha: 1.0) |