[英]iOS update CALayer in UIView animation block
所以我有以下功能
- (void)setMoreMenuHidden:(BOOL)hidden animated:(BOOL)animated completion:(void(^)(BOOL))completion
{
if (!hidden)
{
[self.view layoutIfNeeded];
[self.view setNeedsUpdateConstraints];
[UIView animateWithDuration:0.5f animations:^
{
[self.view layoutIfNeeded];
[_profileInfoVC viewWillLayoutSubviews];
}];
}
}
在_profileInfoVC
我正在执行此操作
-(void)viewWillLayoutSubviews
{
[super viewWillLayoutSubviews];
[self.view layoutIfNeeded];
self.pictureImageView.layer.cornerRadius = self.pictureImageView.frame.size.width/2;
self.pictureImageView.clipsToBounds = YES;
}
因此,我知道动画块中的图层将被忽略,但我认为这也意味着要进行更新,因为在动画过程中和动画之后它仍然保持正方形。 是否有解决方案,不需要我也只为图层创建Core Animation?
因此,您对此感兴趣的块似乎是Completion块。
- (void)setMoreMenuHidden:(BOOL)hidden animated:(BOOL)animated completion:(void(^)(BOOL))completion
{
if (!hidden)
{
[self.view layoutIfNeeded];
[self.view setNeedsUpdateConstraints];
[UIView animateWithDuration:0.5f animations:^
{
[self.view layoutIfNeeded];
}
completion:^(BOOL finished)
{
[_profileInfoVC viewWillLayoutSubviews];
}];
}
}
上面的代码似乎已经解决了我的问题,我也不是真正地直接调用viewWillLayoutSubviews
来将行更改为[_profileInfoVC.view setNeedsLayout];
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.