This should be an easy one -- when I u开发者_开发百科se a CGAffineTransformMakeScale
on a UIView
with width = 0.5
and height = 0.5
, it shrinks to the upper left. I need it to shrink around its center.
How can I achieve that?
Make sure to turn off Autolayout if you are experiencing the same behaviour!
Aha, figured this one out. I was doing some custom drawing and had mixed up frame and bounds.
By default CGAffineTransformMakeScale will scale UIViews around their center.
For example:
[UIView animateWithDuration:0.5 delay:0 options:UIViewAnimationCurveEaseInOut animations:^{
self.myView.transform = CGAffineTransformMakeScale(2, 2);
} completion:nil ];
.. will make the myView twice the size, scaled around its center.
精彩评论