如何解决在过渡期间被导航栏遮罩的titleView?
在我的视图控制器中,我将titleView
设置为包含UIImageView
的UIView
, UIImageView
在其图层上使用setCornerRadius制作成圆形。
圆的上半部分位于导航栏上方,下半部分位于视图上,如下所示:
现在,当我推动这个视图控制器,当它animation时,圆的下半部分被切断,直到animation完成。 只显示导航栏中的部分,如下所示:
一旦推动animation结束,显示完整的圆圈。 有什么办法可以阻止导航栏在animation发生时屏蔽/切断titleView
,以便在animation期间显示整个圆圈?
我不确定你应该这样做。
无论如何:将圆圈添加到您的UIWindow(在您的UINavigationController之上)。 我想你想把圆定位在屏幕的中心(水平)。 您可以使用转换协调器(iOS 7.0 +)在视图控制器转换(推送或popup)的旁边为圆圈设置animation。 请注意, 这只适用于animation转换(即设置animated
时)。 因此,当animated
未设置时,我们需要手动设置新帧。
- (void)viewWillAppear:(BOOL)animated { [super viewWillAppear:animated]; /* Add the circle to the key window (instead of the navigation bar). */ UIWindow *keyWindow = [[UIApplication sharedApplication] keyWindow]; [keyWindow addSubview:_circle]; /* Screen width: the initial position of the circle = center + screen width. */ CGFloat width = self.view.bounds.size.width; CGRect destination = _circle.frame; destination.origin.x = 110.f; /* The transition coordinator is only available for animated transitions. */ if (animated) { CGRect frame = destination; frame.origin.x += width; _circle.frame = frame; void (^animation)(id context) = ^(id context) { _circle.frame = destination; }; [self.transitionCoordinator animateAlongsideTransitionInView:_circle animation:animation completion:animation]; }else { _circle.frame = destination; } }
用你的位置replace110.f
( 110.f = ((320.f - 100.f) / 2.f)
)。
现在,您还需要使用过渡协调器来为stream行音乐制作animation。
- (void)viewWillDisappear:(BOOL)animated { [super viewWillDisappear:animated]; /* Screen width: the initial position of the circle = center + screen width. */ CGFloat width = self.view.bounds.size.width; CGRect destination = _circle.frame; destination.origin.x = 110.f + width; /* The transition coordinator is only available for animated transitions. */ if (animated) { CGRect frame = destination; frame.origin.x = 110.f; _circle.frame = frame; void (^animation)(id context) = ^(id context) { _circle.frame = destination; }; [self.transitionCoordinator animateAlongsideTransitionInView:_circle animation:animation completion:animation]; }else { _circle.frame = destination; } }
最后,一旦你的视图控制器消失了,就从你的关键窗口中删除这个圆圈(注意,这并不一定意味着你的视图控制器被popup,并且你可以在viewWillAppear:
再次将圆形视图读到关键窗口)。
- (void)viewDidDisappear:(BOOL)animated { [super viewDidDisappear:animated]; /* Remove the circle from your key window. */ [_circle removeFromSuperview]; }
- 如何用定时器重复调用一个方法(重新加载…)来为一个转换设置animation
- 如何使用Swift 3制作一个button的animationanimation
- 如何使用CoreAnimationanimation像钟倒计时一样的圆
- b2Bodyanimation?
- 如何将CAGradientLayer作为另一个CALayer的掩码?
- launchscreen.storyboard和main.storyboard有什么不同?
- 如何在IOS中应用部分淡入?
- <Error>:CGAffineTransformInvert:奇异matrix
- 只有在新的iPad 3上:wait_fences:未能收到回复:10004003