我在Xcode中有一个大位图,在其上放置一个弹出窗口(UIView)。默认情况下,它是隐藏的,按下按钮时可见。 当可见时,设置x / y位置......并且它可以工作。
定位后,我希望弹出窗口显示缩放效果。这也有效;但是,x / y定位被忽略,弹出窗口只显示在Storyboard编辑器中的位置。
// Set position
minPopupFrame.origin.x = (_destinationensKoordinater[0] - minPopupFrame.size.width/2 + offsetX) * zoomfaktor;
minPopupFrame.origin.y = (_destinationensKoordinater[1] - minPopupFrame.size.height + offsetY) * zoomfaktor;
_popup.frame = minPopupFrame;
// Scale it to .1
_popup.transform = CGAffineTransformMakeScale(.1, .1);
_popup.hidden = NO;
// Set size to 100% in .3 seconds
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:.3];
_popup.transform = CGAffineTransformMakeScale(1, 1);
[UIView commitAnimations];
这是非常基本的编码 - 但为什么它不起作用?建议,好吗?
编辑:我也尝试了类似的东西 - 但代码完全被忽略了:_popup.hidden = NO;
CGAffineTransform scale = CGAffineTransformMakeScale(1, 1);
CGAffineTransform translate = CGAffineTransformMakeTranslation(200, 200);
CGAffineTransform transform = CGAffineTransformConcat(translate, scale);
_popup.transform = transform;
编辑II:我也试过这个:
_popup.center = CGPointMake((_destinationensKoordinater[0] - minPopupFrame.size.width/2 + offsetX) * zoomfaktor, (_destinationensKoordinater[1] - minPopupFrame.size.height + offsetY) * zoomfaktor);
_popup.transform = CGAffineTransformMakeScale(.1, .1);
_popup.alpha = 0;
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:.3];
_popup.alpha = 1;
_popup.transform = CGAffineTransformMakeScale(1, 1);
[UIView commitAnimations];
有趣的是,alpha动画可以正常工作,但是如果没有注释掉第一个_popup.transform行,则会忽略弹出窗口定位。这对我来说没有意义