Skip to content

Instantly share code, notes, and snippets.

@jerryhjones
Created June 7, 2014 04:01
Show Gist options
  • Save jerryhjones/2f3179fecc454d2e4f6c to your computer and use it in GitHub Desktop.
Save jerryhjones/2f3179fecc454d2e4f6c to your computer and use it in GitHub Desktop.
// Playground - noun: a place where people can play
import UIKit
enum SMPageControlVerticalAlignment {
case Top
case Middle
case Bottom
}
// Used as a class property in SwitchTest.swift
var verticalAlignment = SMPageControlVerticalAlignment.Middle
// Stand-ins for values passed to topOffsetForHeight
var rect = CGRect(x: 0.0, y: 0.0, width: 100.0, height: 100.0)
var height: Float = 10.0
// broken out function from SwitchTest.swift
var top: Float = 0.0
switch verticalAlignment {
case .Middle:
top = CGRectGetMidY(rect) - (height / 2.0)
case .Bottom:
top = CGRectGetMaxY(rect) - height
default:
top = 0.0
}
//
// SwitchTest.swift
// SMPageControlFramework
//
// Created by Jerry Jones on 6/6/14.
// Copyright (c) 2014 Spaceman Labs, Inc. All rights reserved.
//
import UIKit
class SwitchTest: UIView {
enum SMPageControlVerticalAlignment {
case Top
case Middle
case Bottom
}
var verticalAlignment = SMPageControlVerticalAlignment.Middle
init(frame: CGRect) {
super.init(frame: frame)
// Initialization code
}
func topOffsetForHeight(height: Float, rect: CGRect) -> Float
{
var top: Float = 0.0
switch verticalAlignment {
case .Middle:
top = CGRectGetMidY(rect) - (height / 2.0)
case .Bottom:
top = CGRectGetMaxY(rect) - height
default:
top = 0.0
}
return 0.0
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment