I recently read a wonderful question regarding frames & bounds property of views over here - UIView frame, bounds and center. I tried to experiment on that a bit more with autolayout as well and now I find myself in a very conflicting scenario. Please be patient as it may take a bit long.
I will highlight them one by one & so please help me to get over all these -
What I have? -
A view hierachy with constraints as follows - (The designing was done on the default ViewController size of 600*600)
I tried to print out the frames and bounds of these views -
contentView
print(contentView.frame)// o/p - (0.0, 64.0, 600.0, 536.0)
print(contentView.bounds)//o/p- (0.0, 0.0, 600.0, 536.0)
Q) **a)**Why is the frame size showing 600*536 whichever screen I may run it. eg. It prints the same if I run it on a 4s screen or else in an iPad screen?
**b)**And it always infers the size of my VC in my storyboard!!. eg. If i design the screen in a 3.5 inch VC,the frame size becomes 320.0*416.0.
**c)**Since it is pinned to all sides of the view it should be same to the view size, and also it always remains pinned to edges. So why is it not of the same size of self.view.frame.width*self.view.frame.height
sideView
print(sideView.frame)//o/p - (520.0, 86.0, 80.0, 128.0)
print(sideView.bounds)//o/p - (0,0, 80.0, 128.0)
Q) If I design a custom UIView programmatically as
let TestView = UIView(frame: CGRectMake(520.0, 86.0, 80.0, 128.0))//Mark:its frame is exactly same as sideView.frame
TestView.backgroundColor = UIColor.redColor()
self.contentView.addSubview(TestView)
So here the sideView(subview of contentView) should be replaced by the TestView but isn't & the o/p screen comes the same as in previous case. Why?
Thanks.