Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to detect when UIView size is changed in swift ios xcode?

I am trying some stuffs out with CATiledLayer inside UIScrollView.

Somehow, the size of UIView inside the UIScrollView gets changed to a large number. I need to find out exactly what is causing this resize.

Is there a way to detect when the size of UIView(either frame, bounds) or the contentSize of UIScrollView is resized?

I tried

override var frame: CGRect {     didSet {         println("frame changed");     } } 

inside UIView subclass,

but it is only called once when the app starts, although the size of UIView is resized afterwards.

like image 714
Joon. P Avatar asked Jun 03 '15 09:06

Joon. P


People also ask

What is UIView Xcode?

The UIView class is a concrete class that you can instantiate and use to display a fixed background color. You can also subclass it to draw more sophisticated content.


1 Answers

There's an answer here:

https://stackoverflow.com/a/27590915/5160929

Just paste this outside of a method body:

override var bounds: CGRect {     didSet {         // Do stuff here     } } 
like image 121
bearacuda13 Avatar answered Sep 29 '22 02:09

bearacuda13