Created
June 3, 2014 04:17
-
-
Save austinzheng/d68d84b6c57dc61aa297 to your computer and use it in GitHub Desktop.
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
class ViewController: UIViewController { | |
override func viewDidLoad() { | |
super.viewDidLoad() | |
addSquareToView(size: CGSizeMake(30, 30), color: UIColor.greenColor()); | |
} | |
func addSquareToView(size s: CGSize, color: UIColor) { | |
var square: UIView; | |
let frame = CGRectMake(10, 10, s.width, s.height); | |
// This is equivalent to [[UIView alloc] initWithFrame:frame] | |
square = UIView(frame: frame); | |
square.backgroundColor = color; | |
self.view.addSubview(square); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment