ios – UIView动画不起作用

ios – UIView动画不起作用,第1张

概述我想在myView显示器上进行settingView并使用动画消失. 我调用-showSettingView if(!self.settingView):动画正常工作. 但是,如果(self.myView):settingView消失WITHOUT动画. 如何修复它以使settingView与动画一起消失? @property (nonatomic, strong) UIView *myView; 我想在myVIEw显示器上进行settingVIEw并使用动画消失.
我调用-showSettingVIEw
if(!self.settingVIEw):动画正常工作.
但是,如果(self.myVIEw):settingVIEw消失WITHOUT动画.
如何修复它以使settingVIEw与动画一起消失?

@property (nonatomic,strong) UIVIEw *myVIEw;@property (nonatomic,strong) UIVIEw *settingVIEw;- (voID)vIEwDIDLoad{    [super vIEwDIDLoad];    UIbarbuttonItem* settingbutton = [[UIbarbuttonItem alloc]initWithbarbuttonSystemItem:UIbarbuttonSystemItemAction target:self action:@selector(showSettingVIEw)];    self.navigationItem.rightbarbuttonItem = settingbutton;}- (voID)showSettingVIEw{    self.myVIEw = [[UIVIEw alloc]initWithFrame:CGRectMake(0,568,320,480)];    self.myVIEw.opaque = NO;    self.myVIEw.backgroundcolor = [UIcolor colorWithWhite:1.0f Alpha:0.0f];    [self.vIEw addSubvIEw:self.myVIEw];    if (!self.settingVIEw) {        self.settingVIEw = [[UIVIEw alloc]initWithFrame:CGRectMake(0,568)];        self.settingVIEw.backgroundcolor = [UIcolor blackcolor];        [self.myVIEw addSubvIEw:self.settingVIEw];        [UIVIEw animateWithDuration:0.3f                              delay:0.0f                            options:UIVIEwAnimationoptionTransitionFlipFromBottom                         animations:^{self.myVIEw.frame = CGRectMake(0,60,480);}                         completion:^(BOol finished) {}         ];    } else if (self.myVIEw){        self.myVIEw.frame = CGRectMake(0,480);        [UIVIEw animateWithDuration:0.3f                              delay:0.0f                            options:UIVIEwAnimationoptionCurveEaseIn                         animations:^{self.myVIEw.frame = CGRectMake(0,480);}                         completion:^(BOol finished) {}         ];        [self.settingVIEw removeFromSupervIEw];        self.settingVIEw = nil;        [self.myVIEw removeFromSupervIEw];    }}

谢谢.

解决方法 您可以在动画开始之前取消设置视图.试试这个:

[UIVIEw animateWithDuration:0.3f                          delay:0.0f                        options:UIVIEwAnimationoptionCurveEaseIn                     animations:^{self.myVIEw.frame = CGRectMake(0,480);}                     completion:^(BOol finished) {                        [self.settingVIEw removeFromSupervIEw];                        self.settingVIEw = nil;                        [self.myVIEw removeFromSupervIEw];                     }     ];

*另外:如果您使用的是自动布局,则需要执行以下选项之一:

A.在块之前设置myVIEw的约束而不是框架,然后在块内部仅调用layoutIfNeeded:.

B.在动画块中设置transform属性.

总结

以上是内存溢出为你收集整理的ios – UIView动画不起作用全部内容,希望文章能够帮你解决ios – UIView动画不起作用所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/web/1076943.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-26
下一篇 2022-05-26

发表评论

登录后才能评论

评论列表(0条)

保存