在示例中我似乎只能使用变换或正在修改帧.我错过了一些明显的事吗?目前其他动画(淡入淡出)都工作正常,但约束仍然锁定在位.
一个快速的代码片段:
[[customViewController view] layoutIfNeeded];
[UIView animateWithDuration:2 animations:^{
[[customViewController constraintToAnimate] setConstant:1024];
[[customViewController view] layoutIfNeeded];
} completion:^(BOOL finished) {
[transitionContext completeTransition:YES];
}];
Run Code Online (Sandbox Code Playgroud) 我有两个观点,我想做一个轻扫样式转换,我已经完成了当有一个segue行动,但我没有在这里,所以我不知道如何应用我的动画类.我班上的所有内容都是:
let stb = UIStoryboard(name: "Walkthrough", bundle: nil)
let walkthrough = stb.instantiateViewControllerWithIdentifier("walk") as! BWWalkthroughViewController
self.presentViewController(walkthrough, animated: true, completion: nil)
Run Code Online (Sandbox Code Playgroud)
我想申请申请以下自定义segue:
class CustomSegue: UIStoryboardSegue {
override func perform() {
// Assign the source and destination views to local variables.
var firstVCView = self.sourceViewController.view as UIView!
var secondVCView = self.destinationViewController.view as UIView!
// Get the screen width and height.
let screenWidth = UIScreen.mainScreen().bounds.size.width
let screenHeight = UIScreen.mainScreen().bounds.size.height
// Specify the initial position of the destination view.
secondVCView.frame = CGRectMake(0.0, screenHeight, screenWidth, screenHeight) …Run Code Online (Sandbox Code Playgroud) 我的应用程序有两个视图控制器(VC A和B)以及它们之间的自定义转换.
当在VC A上使用左向平移手势时,交互式动画过渡在模式上呈现VC B从A向右滑动(从右到左).要关闭VC B,用户可以:
UIPercentDrivenInteractiveTransition对象"驱动" .问题是在Xcode 10 Seed(build 10A254a)+ iOS 12 Simulator(X或XR或XS)上进行测试我可以很容易地进入自定义转换永远不会完成且UI处于奇怪状态的状态:
此问题从未出现在任何先前版本的Xcode和/或iOS Xcode 10/iOS12之前.
这是animateTransition我的自定义方法UIViewControllerAnimatedTransitioning
func animateTransition(using transitionContext: UIViewControllerContextTransitioning) {
guard let fromVC = transitionContext.viewController(forKey: .from), let toVC = transitionContext.viewController(forKey: .to) else {
transitionContext.completeTransition(false)
return
}
let containterView = transitionContext.containerView
containterView.insertSubview(toVC.view, …Run Code Online (Sandbox Code Playgroud) 我是iOS开发中的新手,最近在iOS 9中通过自定义过渡遇到了这个问题.
我有一个对象符合UIViewControllerTransitioningDelegate协议和实现animationControllerForDismissedController,如:
@implementation MyCustomizedTransitioningDelegate
#pragma mark - UIViewControllerTransitioningDelegate
- (id<UIViewControllerAnimatedTransitioning>)animationControllerForDismissedController:(UIViewController *)dismissed
{
MyCustomizedTransitionAnimator *animator = [[MyCustomizedTransitionAnimator alloc] init];
animator.presenting = NO;
return animator;
}
@end
Run Code Online (Sandbox Code Playgroud)
触发模态转换的过程如下:
@implementation MyViewController
#pragma mark - Initializers
+ (MyCustomizedTransitioningDelegate *)modalTransitioningDelegateSingletonInstance;
{
static MyCustomizedTransitioningDelegate *delegateInst = nil;
static dispatch_once_t onceToken = 0;
dispatch_once(&onceToken, ^{
delegateInst = [[MyCustomizedTransitioningDelegate alloc] init];
});
return delegateInst;
}
#pragma mark - UIViewController
- (void)dismissViewControllerAnimated:(BOOL)animated completion:(void (^)(void))completion;
{
[self prepareForDismissViewControllerAnimated:animated completion:&completion];
[super dismissViewControllerAnimated:animated completion:completion];
}
- (void)prepareForDismissViewControllerAnimated:(BOOL)animated …Run Code Online (Sandbox Code Playgroud) 我想在具有不同UINavigationBar背景颜色的视图之间实现流畅的动画。嵌入的视图具有相同的背景颜色UINavigationBar,我想模仿推/弹出过渡动画,如:
我准备了自定义过渡:
class CustomTransition: NSObject, UIViewControllerAnimatedTransitioning {
private let duration: TimeInterval
private let isPresenting: Bool
init(duration: TimeInterval = 1.0, isPresenting: Bool) {
self.duration = duration
self.isPresenting = isPresenting
}
func transitionDuration(using transitionContext: UIViewControllerContextTransitioning?) -> TimeInterval {
return duration
}
func animateTransition(using transitionContext: UIViewControllerContextTransitioning) {
let container = transitionContext.containerView
guard
let toVC = transitionContext.viewController(forKey: .to),
let fromVC = transitionContext.viewController(forKey: .from),
let toView = transitionContext.view(forKey: .to),
let fromView = transitionContext.view(forKey: .from)
else {
return
}
let rightTranslation = …Run Code Online (Sandbox Code Playgroud) 我有一个View控制器,当点击表格单元格时,它具有自定义推送转换,并在点击后退栏按钮项目时执行标准弹出转换.问题是当我尝试从前一个控制器转到相同的视图控制器时,应用程序崩溃了.以下是UINavigationControllerDelegate我正在实现的功能:
- (id<UIViewControllerAnimatedTransitioning>)navigationController:(UINavigationController *)navigationController animationControllerForOperation:(UINavigationControllerOperation)operation fromViewController:(UIViewController *)fromVC toViewController:(UIViewController *)toVC
{
return (operation == UINavigationControllerOperationPush ? animator : nil);
}
Run Code Online (Sandbox Code Playgroud)
任何线索都表示赞赏!
提前致谢.