で困っていCGAffineTransformMakeScale
ます。以下のコードを使用してビューを表示し、非表示にしています。初めてそれが表示され、完全に却下されました。しかし、その後は再び表示されません。ログを印刷した後、実際には画面座標から外れていました。
私は却下でリセット変換を適用しましたが、使用しCGAffineTransformIdentity
ていますが、まだ正しく機能していません。
- (void) showWithAnimation
{
float mheight = customView.frame.size.height;
UIWindow *keyWindow = [UIApplication sharedApplication].keyWindow;
if(!keyWindow)
{
NSArray *windows = [UIApplication sharedApplication].windows;
if(windows.count > 0)
keyWindow = [windows lastObject];
keyWindow = [windows objectAtIndex:0];
}
UIView *containerView = [[keyWindow subviews] objectAtIndex:0];
CGRect frame = customView.frame;
frame.origin.y = -mheight;
customView.frame = frame;
NSLog(@"customView - %@", customView);
[containerView addSubview:customView];
customView.alpha = 0;
customView.transform = CGAffineTransformMakeScale(0.01, 0.01);
customView.center = CGPointMake((ScreenBounds().size.width / 2) - 24, ScreenBounds().size.height / 2);
NSLog(@"customView After applying transfrom - %@", customView);
[UIView animateWithDuration:0.3
delay:0.0
options:UIViewAnimationCurveEaseInOut
animations:^{
customView.transform = CGAffineTransformMakeScale(1, 1);
customView.alpha = 1;
}
completion:^(BOOL finished){
self.isVisible = YES;
NSLog(@"customView Displayed .....");
NSLog(@"customView - %@", customView);
}];
}
- (void)dismissWithAnimation
{
[UIView animateWithDuration:0.3
delay:0.0
options:UIViewAnimationCurveEaseInOut
animations:^{
customView.transform = CGAffineTransformMakeScale(0.01, 0.01);
customView.alpha = 0;
}
completion:^(BOOL finished)
{
self.isVisible = NO;
**//Edit: I tried applying CGAffineTransformIdentity at here**
[customView removeFromSuperview];
}];
}
以下はログです。
--> 1st time logs
customView -> <UIView: 0x205a1e50; frame = (24 -150; 272 150); layer = <CALayer: 0x205a1eb0>>
customView After applying transfrom - <UIView: 0x205a1e50; frame = (134.64 283.25; 2.72 1.5); transform = [0.01, 0, 0, 0.01, 0, 0]; alpha = 0; layer = <CALayer: 0x205a1eb0>>
customView Displayed .....
customView - <UIView: 0x205a1e50; frame = (0 209; 272 150); layer = <CALayer: 0x205a1eb0>>
--> 2nd time logs
customView -> <UIView: 0x205a1e50; frame = (24 -204; 272 204); transform = [0.01, 0, 0, 0.01, 0, 0]; alpha = 0; animations = { transform=<CABasicAnimation: 0x2072c620>; opacity=<CABasicAnimation: 0x2072df20>; }; layer = <CALayer: 0x205a1eb0>>
customView After applying transfrom - <UIView: 0x205a1e50; frame = (3.03984e-06 182; 272 204); transform = [0.01, 0, 0, 0.01, 0, 0]; alpha = 0; animations = { transform=<CABasicAnimation: 0x2072c620>; opacity=<CABasicAnimation:
0x2072df20>; }; layer = <CALayer: 0x205a1eb0>>
customView Displayed .....
customView - <UIView: 0x205a1e50; frame = (-13464 -9916; 27200 20400); layer = <CALayer: 0x205a1eb0>>
ここで何が起こっているのか。