Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to resize UIView in iOS?

I have got a main view and a view1 into main view, how to resize view1?

This code doesn't work:

self.View1.bounds.size.height = self.view.bounds.size.height;
like image 931
Vincenzo Putignano Avatar asked Oct 16 '13 17:10

Vincenzo Putignano


2 Answers

CGRect frame = self.View1.frame;
frame.size.height = self.view.bounds.size.height;
self.View1.frame = frame;
like image 122
Tony Friz Avatar answered Oct 10 '22 07:10

Tony Friz


You can't modify the bounds directly. The CGRect needs to be modified outside of the view's bounds.

CGRect viewBounds = self.view1.bounds;
viewBounds.size.height = self.view.bounds.size.height;
self.view1.bounds = viewBounds;

Hope this helps!

like image 21
cdownie Avatar answered Oct 10 '22 09:10

cdownie