Skip to content
Permalink
Browse files

Merge pull request #5 from younata/styleStartScene

Add ability to style more things
  • Loading branch information...
dasdom committed Sep 13, 2015
2 parents 805558b + e47d455 commit 6ba27f2f0a727c5e686b5b2f9ddc1a1dadf12ec6
Showing with 49 additions and 24 deletions.
  1. +47 −23 PullToRefreshDemo/BreakOutToRefreshView.swift
  2. +2 −1 PullToRefreshDemo/DemoTableViewController.swift
@@ -48,6 +48,14 @@ public class BreakOutToRefreshView: SKView {
public var scenebackgroundColor: UIColor {
didSet {
breakOutScene.scenebackgroundColor = scenebackgroundColor
startScene.backgroundColor = scenebackgroundColor
}
}

public var textColor: UIColor {
didSet {
breakOutScene.textColor = textColor
startScene.textColor = textColor
}
}

@@ -68,12 +76,20 @@ public class BreakOutToRefreshView: SKView {
}
}

private lazy var startScene: StartScene = {
let size = CGSize(width: self.scrollView.frame.size.width, height: self.sceneHeight)
let startScene = StartScene(size: size)
startScene.backgroundColor = self.scenebackgroundColor
return startScene
}()

public override init(frame: CGRect) {
assert(false, "Use init(scrollView:) instead.")
breakOutScene = BreakOutScene(size: frame.size)
scrollView = UIScrollView()

scenebackgroundColor = UIColor.whiteColor()
textColor = UIColor.blackColor()
paddleColor = UIColor.whiteColor()
ballColor = UIColor.whiteColor()
blockColors = [UIColor.whiteColor()]
@@ -90,11 +106,13 @@ public class BreakOutToRefreshView: SKView {
self.scrollView = inScrollView

scenebackgroundColor = UIColor.whiteColor()
textColor = UIColor.blackColor()
paddleColor = UIColor.grayColor()
ballColor = UIColor.blackColor()
blockColors = [UIColor(white: 0.2, alpha: 1.0), UIColor(white: 0.4, alpha: 1.0), UIColor(white: 0.6, alpha: 1.0)]

breakOutScene.scenebackgroundColor = scenebackgroundColor
breakOutScene.textColor = textColor
breakOutScene.paddleColor = paddleColor
breakOutScene.ballColor = ballColor
breakOutScene.blockColors = blockColors
@@ -104,7 +122,7 @@ public class BreakOutToRefreshView: SKView {
layer.borderColor = UIColor.grayColor().CGColor
layer.borderWidth = 1.0

presentScene(StartScene(size: frame.size))
presentScene(startScene)
}

public required init(coder aDecoder: NSCoder) {
@@ -191,6 +209,7 @@ class BreakOutScene: SKScene, SKPhysicsContactDelegate {
var isStarted = false

var scenebackgroundColor: UIColor!
var textColor: UIColor!
var paddleColor: UIColor!
var ballColor: UIColor!
var blockColors: [UIColor]!
@@ -321,7 +340,7 @@ class BreakOutScene: SKScene, SKPhysicsContactDelegate {

func createLoadingLabelNode() {
let loadingLabelNode = SKLabelNode(text: "Loading...")
loadingLabelNode.fontColor = UIColor.lightGrayColor()
loadingLabelNode.fontColor = textColor
loadingLabelNode.fontSize = 20
loadingLabelNode.position = CGPoint(x: CGRectGetMidX(frame), y: CGRectGetMidY(frame))
loadingLabelNode.name = backgroundLabelName
@@ -409,39 +428,44 @@ class StartScene: SKScene {

var contentCreated = false

override func didMoveToView(view: SKView) {
super.didMoveToView(view)
if !contentCreated {
createSceneContents()
contentCreated = true
var textColor = SKColor.blackColor() {
didSet {
self.startLabelNode.fontColor = textColor
self.descriptionLabelNode.fontColor = textColor
}
}

func createSceneContents() {
backgroundColor = SKColor.whiteColor()
scaleMode = .AspectFit
addChild(startLabelNode())
addChild(descriptionLabelNode())
}

func startLabelNode() -> SKLabelNode {

lazy var startLabelNode: SKLabelNode = {
let startNode = SKLabelNode(text: "Pull to Break Out!")
startNode.fontColor = UIColor.blackColor()
startNode.fontColor = self.textColor
startNode.fontSize = 20
startNode.position = CGPoint(x: CGRectGetMidX(frame), y: CGRectGetMidY(frame))
startNode.position = CGPoint(x: CGRectGetMidX(self.frame), y: CGRectGetMidY(self.frame))
startNode.name = "start"

return startNode
}
func descriptionLabelNode() -> SKLabelNode {
}()

lazy var descriptionLabelNode: SKLabelNode = {
let descriptionNode = SKLabelNode(text: "Scroll to move handle")
descriptionNode.fontColor = UIColor.blackColor()
descriptionNode.fontColor = self.textColor
descriptionNode.fontSize = 17
descriptionNode.position = CGPoint(x: CGRectGetMidX(frame), y: CGRectGetMidY(frame)-20)
descriptionNode.position = CGPoint(x: CGRectGetMidX(self.frame), y: CGRectGetMidY(self.frame)-20)
descriptionNode.name = "description"

return descriptionNode
}()

override func didMoveToView(view: SKView) {
super.didMoveToView(view)
if !contentCreated {
createSceneContents()
contentCreated = true
}
}

func createSceneContents() {
scaleMode = .AspectFit
addChild(startLabelNode)
addChild(descriptionLabelNode)
}
}
@@ -21,10 +21,11 @@ class DemoTableViewController: UITableViewController {

// configure the refresh view
// refreshView.scenebackgroundColor = UIColor(hue: 0.68, saturation: 0.9, brightness: 0.3, alpha: 1.0)
// refreshView.textColor = UIColor.whiteColor()
// refreshView.paddleColor = UIColor.lightGrayColor()
// refreshView.ballColor = UIColor.whiteColor()
// refreshView.blockColors = [UIColor(hue: 0.17, saturation: 0.9, brightness: 1.0, alpha: 1.0), UIColor(hue: 0.17, saturation: 0.7, brightness: 1.0, alpha: 1.0), UIColor(hue: 0.17, saturation: 0.5, brightness: 1.0, alpha: 1.0)]
tableView.addSubview(refreshView)

}

0 comments on commit 6ba27f2

Please sign in to comment.
You can’t perform that action at this time.