objective c - NSWindow animate size change new subview with auto layout -
i have nswindowcontroller
containing several nsviewcontroller
. windowcontroller displays view of first viewcontroller subview of main window.
on button click windowcontroller adds next viewcontrollers view subview, adds layout constraints , animates them first view moves out , next view moves in. after animation first view removed superview.
[nextcontroller setleftlayoutconstraint:nextleft]; // ^^^^^^^^^^^^^^^^^^^^^^^ custom category'd property [containerview addsubview:nextview]; [containerview addconstraints:@[nextwidth, nextheight, nexttop, nextleft]]; [nsanimationcontext runanimationgroup:^(nsanimationcontext *context) { [context settimingfunction:[camediatimingfunction functionwithname:kcamediatimingfunctioneaseout]]; [context setduration:0.5]; [[nextleft animator] setconstant:[self leftoffset]]; [[[[self currentviewcontroller] view] animator] setalphavalue:-0.25]; // negative alpha shift timing [[[[self currentviewcontroller] leftlayoutconstraint] animator] setconstant:-nswidth(containerview.frame)]; // ^^^^^^^^^^^^^^^^^^^^ custom category'd property } completionhandler:^{ [[[self currentviewcontroller] view] setalphavalue:1.0]; [[[self currentviewcontroller] view] removefromsuperview]; [[self currentviewcontroller] removefromparentviewcontroller]; _currentviewcontroller = nextcontroller; }];
now second view taller first changes windows hight well.
unfortunately window frame change not animated , window pops ugly in right size.
i tried getting next views hight first animate constraints or this. unfortunately views not in correct size before animation done.
is there way animate window change well?
Comments
Post a Comment