How do I change UIView Size?

SKYnine picture SKYnine · Nov 3, 2014 · Viewed 194k times · Source

I have trouble with modifying my UIView height at launch.

I have to UIView and I want one to be screen size * 70 and the other to fill the gap.

here is what I have

 @IBOutlet weak var questionFrame: UIView!
 @IBOutlet weak var answerFrame: UIView!
 let screenSize:CGRect = UIScreen.mainScreen().bounds

and

 questionFrame.frame.size.height = screenSize.height * 0.70
 answerFrame.frame.size.height = screenSize.height * 0.30

It has no effect on the app during run time. I use autolayout but I only have margins constraints...

Am I doing it all wrong?

Answer

User4 picture User4 · Nov 3, 2014

Here you go. this should work.

questionFrame.frame = CGRectMake(0 , 0, self.view.frame.width, self.view.frame.height * 0.7) 

answerFrame.frame =  CGRectMake(0 , self.view.frame.height * 0.7, self.view.frame.width, self.view.frame.height * 0.3)