Created
September 20, 2016 19:56
-
-
Save johndpope-karhoo/cd5149d14bdf51632e952994eb2f7d4c to your computer and use it in GitHub Desktop.
Revisions
-
johndpope-karhoo created this gist
Sep 20, 2016 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,60 @@ import Foundation import SnapKit let screenWidth = UIScreen.mainScreen().bounds.width class SnapKitHelperView:UIView{ var debugConstraints = false override func layoutSubviews() { super.layoutSubviews() if(debugConstraints){ for c in self.constraints{ print("constraints:",c.firstAttribute) } self.backgroundColor = self.getRandomColor(); } } func labelByTag(tag:Int) -> UILabel{ if let view = self.viewWithTag(tag) as? UILabel{ return view; }else{ print("FATAL missing label by tag ",tag) fatalError() } return UILabel() } func viewByTag(tag:Int) -> UIView{ if let view = self.viewWithTag(tag){ return view; }else{ print("FATAL missing view by tag ",tag) fatalError() } return UIView() } func imageViewByTag(tag:Int) -> UIImageView{ if let view = self.viewWithTag(tag) as? UIImageView{ return view; }else{ print("FATAL missing image by tag ",tag) fatalError() } return UIImageView() } func getRandomColor() -> UIColor{ let randomGreen:CGFloat = CGFloat(drand48()) let randomBlue:CGFloat = CGFloat(drand48()) return UIColor(red: 1, green: randomGreen, blue: randomBlue, alpha: 1.0) } }