Last active
August 29, 2015 14:21
-
-
Save collinsrj/967c4948b7c7a1866770 to your computer and use it in GitHub Desktop.
An Xcode playground showing a custom UIView
This file contains 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 | |
import XCPlayground | |
class MyView: UIView { | |
override init(frame: CGRect) { | |
super.init(frame: frame) | |
setup() | |
} | |
required init(coder aDecoder: NSCoder) { | |
super.init(coder: aDecoder) | |
setup() | |
} | |
override func drawRect(rect: CGRect) { | |
let path = UIBezierPath() | |
path.moveToPoint(CGPoint(x: 10, y: 10)) | |
path.addLineToPoint(CGPoint(x: 100,y: 10)) | |
path.addLineToPoint(CGPoint(x: 100,y: 100)) | |
path.addLineToPoint(CGPoint(x: 10, y: 100)) | |
path.closePath() | |
UIColor.redColor().setStroke() | |
path.lineWidth = 3 | |
path.stroke() | |
} | |
func setup() { | |
backgroundColor = UIColor.whiteColor() | |
} | |
} | |
let myView = MyView(frame: CGRect(x: 0, y: 0, width: 200, height: 300)) | |
XCPShowView("Demo Square", myView) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment