Skip to content

Instantly share code, notes, and snippets.

@senthilvs7
Forked from binishkaspar/simulation.swift
Last active August 29, 2015 14:27
Show Gist options
  • Select an option

  • Save senthilvs7/23b6ab61ac927972ca90 to your computer and use it in GitHub Desktop.

Select an option

Save senthilvs7/23b6ab61ac927972ca90 to your computer and use it in GitHub Desktop.
iPhone View Simulation on Playground
import XCPlayground
import UIKit
import QuartzCore
let zoom:CGFloat = 0.5
let deviceSize = CGSize(width: 640*zoom, height: 1136*zoom)
let statusBarHeight:CGFloat = 48*zoom
let navBarHeight:CGFloat = 88*zoom
let tabBarHeight:CGFloat = 98*zoom
let bgColor = UIColor(white: 0, alpha: 0.01)
let showStatusBar = true
let font = UIFont(name: "HelveticaNeue-Light", size: 62)
let view = UIView(frame: CGRect(x: 0, y: 0, width: deviceSize.width, height: deviceSize.height))
XCPShowView("iphone", view)
view.backgroundColor = bgColor
var frame = view.frame
frame.size.height = statusBarHeight
let sview = UIView(frame: frame)
if showStatusBar{
sview.backgroundColor = UIColor(white: 0, alpha: 0.4)
view.addSubview(sview)
}
let label = UILabel(frame: CGRect.zeroRect)
label.frame.origin.y = 100
label.text = "Hello\nPlayground"
label.numberOfLines = 2
label.font = font
label.sizeToFit()
view.addSubview(label)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment