Last active
June 14, 2017 18:19
-
-
Save AdibContractorCC/fdcc089e48025fd3f78db2e3ffd31d79 to your computer and use it in GitHub Desktop.
Draw hats!
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
let rect = observation.boundingBox.denormalized(newRect: self.view.frame) | |
let hatWidth = rect.size.width | |
let hatHeight = rect.size.height | |
let hatX = rect.origin.x - hatWidth/4 | |
let hatY = rect.origin.y - hatHeight | |
let hatRect = CGRect(x: hatX, y: hatY, width: hatWidth, height: hatHeight) | |
var hat : UIImageView? = nil | |
if faceNumber >= self.hats.count { | |
hat = UIImageView(frame: hatRect) | |
hat!.image = UIImage.init(named: "hat") | |
self.hats.append(hat!) | |
} | |
else { | |
hat = self.hats[faceNumber] | |
hat!.frame = hatRect | |
} | |
self.view.addSubview(hat!) | |
hat!.isHidden = false |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment