Question

I have an view inside a UIScrollView. On that view I set a scale transform, so it compensates for the zooming and stays the same size.

While the transform seems to work on all subviews, filling the bounds in the view's own drawRect seems to fill the whole frame, as if there was no scale transform applied.

Why can this be?

Was it helpful?

Solution

I was aware that I could not use the frame property in a transformed view, but actually setting it yourself on a transformed view is also a no-no.

if the transform property contains a non-identity transform, the value of the frame property is undefined and should not be modified

I removed all code that uses self.frame in any way and used self.center instead. Now everything displays correctly.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top