我有一个图像“oeuf2”whitch位于屏幕的中心,我添加了这段代码:
[UIView transitionWithView:oeuf2 duration:0.5 options:UIViewAnimationOptionTransitionNone animations:^(void) {
CGRect newRect = oeuf2.frame;
newRect.size.width = 300;
oeuf2.frame = newRect;
} completion:^(BOOL finished) {
}];
增加宽度。但是当我这样做时,图像移动也是它的中心,所以我的问题是如何在不改变其位置的情况下增加“oeuf2”的宽度。
答案 0 :(得分:1)
尝试使用
CGPoint center = oeuf2.center;
//Change the frame here
oeuf2.center = center;
希望这有帮助。