Created
May 31, 2015 04:47
-
-
Save CodySwannGT/4d2325168d6240248b1c to your computer and use it in GitHub Desktop.
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
override func viewDidLayoutSubviews() { | |
// 10% for X button | |
// 15% for avatar bar | |
// 25% for war pic | |
// remainder for tables | |
if (layoutsCalled >= 2) { | |
return | |
} | |
layoutsCalled++ | |
let screenSize: CGRect = UIScreen.mainScreen().bounds | |
let screenWidth = screenSize.width | |
let screenHeight = screenSize.height | |
var currFrame:CGRect = CGRect(x: 0, y: 0, width: screenWidth, height: screenHeight) | |
self.view.frame = currFrame | |
println(self.view.frame.size) | |
var w:Int = Int(self.view.frame.width) | |
var h:Int = Int(self.view.frame.height) | |
println("w and h: \(w) \(h)") | |
currFrame = CGRect(x: 11, y: 25, width: 20, height: 20) | |
X.frame = currFrame | |
X.layer.zPosition = 100 | |
currFrame = CGRect(x: 10, y: 50, width: w-20, height: 50) | |
blueBar1.frame = currFrame | |
blueBar1.layer.zPosition = 0 | |
currFrame = CGRect(x: 10, y:50, width: 50, height: 50) | |
avatar1.frame = currFrame | |
avatar1.layer.zPosition = 100 | |
currFrame = CGRect(x: 10 + (50 - act1.frame.width)/2, y:50 + (50-act1.frame.height)/2, width: act1.frame.width, height: act1.frame.height) | |
act1.frame = currFrame | |
act1.layer.zPosition = 3 | |
var xx:Int = (w-10 - (50 - Int(act1.frame.width))/2) | |
var ww:Int = Int(act2.frame.width) | |
var hh:Int = Int(act2.frame.height) | |
var yy:Int = 50 + (50-Int(act1.frame.height))/2 | |
currFrame = CGRect(x: xx, y: yy, width: ww, height: hh) | |
act2.frame = currFrame | |
act2.layer.zPosition = 3 | |
currFrame = CGRect(x: w-60, y:50, width: 50, height: 50) | |
avatar2.frame = currFrame | |
avatar2.layer.zPosition = 100 | |
currFrame = CGRect(x: 65, y:52, width: (w-130)/2, height: 20) | |
name1.frame = currFrame | |
name1.layer.zPosition = 1 | |
currFrame = CGRect(x: w/2, y:52, width: (w-130)/2, height: 20) | |
name2.frame = currFrame | |
name2.layer.zPosition = 1 | |
currFrame = CGRect(x: 22, y:75, width: w-45, height: 50) | |
slider.frame = currFrame | |
slider.layer.zPosition = 2 | |
println("warpic: (want) 10 100 \(w-20) \(h/3)") | |
currFrame = CGRect(x: 10, y:100, width: w-20, height: h/3) | |
warPic.frame = currFrame | |
warPic.layer.zPosition = -100 | |
println("warpic: (have) \(warPic.frame.origin.x) \(warPic.frame.origin.y) \(warPic.frame.width) \(warPic.frame.height)") | |
currFrame = CGRect(x: 10, y:140, width: w-20, height: h/3) | |
bet.frame = currFrame | |
bet.layer.zPosition = 4 | |
yy = Int(topOf(warPic)) + Int(warPic.frame.height)/3 | |
xx = (ww - Int(warAct.frame.width))/2 | |
ww = Int(warAct.frame.width) | |
hh = Int(warAct.frame.height) | |
currFrame = CGRect(x: xx, y: yy, width: ww, height: hh) | |
warAct.frame = currFrame | |
warAct.layer.zPosition = 3 | |
yy = Int(bottomOf(warPic)) | |
currFrame = CGRect(x: 10, y:yy, width: (w-20)/2, height: 30) | |
prizeBG = UIImageView() | |
prizeBG.backgroundColor = AppDelegate.UIColorFromRGB(0x2FCDD0FF) | |
prizeBG.frame = currFrame | |
prizeBG.layer.zPosition = 0 | |
self.view.addSubview(prizeBG) | |
currFrame = CGRect(x: 20, y:yy + 2, width: 20, height: 25) | |
prizeIcon = UIImageView() | |
prizeIcon.image = UIImage(named: "award.png") | |
prizeIcon.backgroundColor = UIColor.clearColor() | |
prizeIcon.frame = currFrame | |
self.view.addSubview(prizeIcon) | |
currFrame = CGRect(x: 50, y:yy + 2, width: w-100, height: 25) | |
prizeText = UILabel() | |
prizeText.backgroundColor = UIColor.clearColor() | |
prizeText.textColor = UIColor.whiteColor() | |
prizeText.text = theWar!.prize! | |
prizeText.frame = currFrame | |
self.view.addSubview(prizeText) | |
currFrame = CGRect(x: w-50, y:yy + 2, width: 25, height: 25) | |
ellipses = UIButton.buttonWithType(.System) as! UIButton | |
ellipses.backgroundColor = UIColor.clearColor() | |
ellipses.frame = currFrame | |
ellipses.layer.zPosition = 100 | |
ellipses.setImage(UIImage(named: "ellipses.png"), forState: .Normal) | |
self.view.addSubview(ellipses) | |
ellipses.addTarget(self, action: "ellipsesTapped:", forControlEvents: .TouchUpInside) | |
yy = Int(bottomOf(prizeBG)) | |
currFrame = CGRect(x: 10, y:yy, width: (w-20)/2, height: 30) | |
showComments = UIButton.buttonWithType(.System) as! UIButton | |
showComments.backgroundColor = AppDelegate.UIColorFromRGB(0x2FCDD0FF) | |
showComments.titleLabel!.font = UIFont(name: "Avenir Next", size: 20) | |
showComments.setTitleColor(UIColor.whiteColor(), forState: .Normal) | |
showComments.frame = currFrame | |
showComments.layer.zPosition = 1 | |
showComments.setTitle("Comments", forState: .Normal) | |
self.view.addSubview(showComments) | |
showComments.addTarget(self, action: "showComments:", forControlEvents: .TouchUpInside) | |
currFrame = CGRect(x: w/2, y:yy, width: (w-20)/2, height: 30) | |
showSiding = UIButton.buttonWithType(.System) as! UIButton | |
showSiding.backgroundColor = AppDelegate.UIColorFromRGB(0x2FCDD0FF) | |
showSiding.titleLabel!.font = UIFont(name: "Avenir Next", size: 20) | |
showSiding.setTitleColor(UIColor.whiteColor(), forState: .Normal) | |
showSiding.frame = currFrame | |
showSiding.layer.zPosition = 1 | |
showSiding.setTitle("Siding", forState: .Normal) | |
self.view.addSubview(showSiding) | |
showSiding.addTarget(self, action: "showSiding:", forControlEvents: .TouchUpInside) | |
currFrame = CGRect(x: 10, y:yy + 30, width: (w-20), height: 30) | |
commentBG = UIImageView() | |
commentBG.backgroundColor = AppDelegate.UIColorFromRGB(0x2FCDD0FF) | |
commentBG.frame = currFrame | |
commentBG.layer.zPosition = 0 | |
self.view.addSubview(commentBG) | |
currFrame = CGRect(x: 15, y:yy + 33, width: w-20 - 50, height: 20) | |
commentText = UITextField() | |
commentText.frame = currFrame | |
commentText.borderStyle = UITextBorderStyle.RoundedRect | |
commentText.layer.borderColor = UIColor.whiteColor().CGColor | |
// commentText.placeholder = "Enter New Comment" | |
commentText.backgroundColor = UIColor.whiteColor() | |
commentText.textColor = UIColor.blackColor() | |
commentText.enabled = true | |
commentText.userInteractionEnabled = true | |
commentText.delegate = self | |
commentText.layer.zPosition = 1 | |
self.view.addSubview(commentText) | |
currFrame = CGRect(x: w-20-38, y:yy + 33, width: 35, height: 20) | |
goButton = UIButton.buttonWithType(.System) as! UIButton | |
goButton.backgroundColor = AppDelegate.UIColorFromRGB(0x2FCDD0FF) | |
goButton.titleLabel!.font = UIFont(name: "Avenir Next", size: 12) | |
goButton.setTitleColor(UIColor.blackColor(), forState: .Normal) | |
goButton.setTitle("GO", forState: .Normal) | |
goButton.addTarget(self, action: "go:", forControlEvents: .TouchUpInside) | |
goButton.frame = currFrame | |
goButton.layer.zPosition = 1 | |
self.view.addSubview(goButton) | |
currFrame = CGRect(x: 10, y:yy + 58, width: w-20, height: h-yy-58) | |
commentTable = UITableView() | |
commentTable.frame = currFrame | |
commentTable.layer.zPosition = 1 | |
var nib = UINib(nibName: "WarCommentTableViewCell", bundle: nil) | |
commentTable.registerNib(nib, forCellReuseIdentifier: "comment") | |
commentTable.separatorColor = AppDelegate.UIColorFromRGB(0x42a6dd) | |
commentTable.separatorStyle = UITableViewCellSeparatorStyle.None | |
commentTable.rowHeight = 80 | |
commentTable.backgroundColor = AppDelegate.UIColorFromRGB(0xFFFFFF33) | |
var refreshControl = UIRefreshControl() | |
refreshControl.addTarget(self, action: Selector("refreshComments"), forControlEvents: UIControlEvents.ValueChanged) | |
self.refreshControl = refreshControl | |
commentTable.addSubview(refreshControl) | |
commentTable.delegate = self | |
commentTable.dataSource = self | |
if (mode == 0) { | |
commentTable.hidden = false | |
} else { | |
commentTable.hidden = true | |
} | |
self.view.addSubview(commentTable) | |
currFrame = CGRect(x: 10, y:yy + 58, width: w/2-10, height: h-yy-38) | |
sidingTable1 = UITableView() | |
sidingTable1.frame = currFrame | |
sidingTable1.layer.zPosition = 4 | |
nib = UINib(nibName: "Sider", bundle: nil) | |
sidingTable1.registerNib(nib, forCellReuseIdentifier: "side1") | |
sidingTable1.separatorColor = AppDelegate.UIColorFromRGB(0x42a6dd) | |
sidingTable1.separatorStyle = UITableViewCellSeparatorStyle.None | |
sidingTable1.rowHeight = 50 | |
sidingTable1.backgroundColor = AppDelegate.UIColorFromRGB(0xFFFFFF33) | |
// var refreshControl = UIRefreshControl() | |
// refreshControl.addTarget(self, action: Selector("refreshComments"), forControlEvents: UIControlEvents.ValueChanged) | |
// self.refreshControl = refreshControl | |
// commentTable.addSubview(refreshControl) | |
sidingTable1.delegate = self | |
sidingTable1.dataSource = self | |
if (mode == 1) { | |
sidingTable1.hidden = false | |
} else { | |
sidingTable1.hidden = true | |
} | |
self.view.addSubview(sidingTable1) | |
currFrame = CGRect(x: w/2, y:yy + 58, width: w/2-10, height: h-yy-58) | |
sidingTable2 = UITableView() | |
sidingTable2.frame = currFrame | |
sidingTable2.layer.zPosition = 1 | |
nib = UINib(nibName: "Sider", bundle: nil) | |
sidingTable2.registerNib(nib, forCellReuseIdentifier: "side2") | |
sidingTable2.separatorColor = AppDelegate.UIColorFromRGB(0x42a6dd) | |
sidingTable2.separatorStyle = UITableViewCellSeparatorStyle.None | |
sidingTable2.rowHeight = 50 | |
sidingTable2.backgroundColor = AppDelegate.UIColorFromRGB(0xFFFFFF33) | |
// var refreshControl = UIRefreshControl() | |
// refreshControl.addTarget(self, action: Selector("refreshComments"), forControlEvents: UIControlEvents.ValueChanged) | |
// self.refreshControl = refreshControl | |
// commentTable.addSubview(refreshControl) | |
sidingTable2.delegate = self | |
sidingTable2.dataSource = self | |
if (mode == 1) { | |
sidingTable2.hidden = false | |
} else { | |
sidingTable2.hidden = true | |
} | |
self.view.addSubview(sidingTable2) | |
// for subview in self.view.subviews { | |
// subview.setTranslatesAutoresizingMaskIntoConstraints(false) | |
// } | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment