-(void)pauseLayer:(CALayer*)layer {
CFTimeInterval pausedTime = [layer convertTime:CACurrentMediaTime() fromLayer:nil];
layer.speed = 0.0;
layer.timeOffset = pausedTime;
}
-(void)resumeLayer:(CALayer*)layer{
CFTimeInterval pausedTime = [layer timeOffset];
layer.speed = 1.0;
layer.timeOffset = 0.0;
layer.beginTime = 0.0;
CFTimeInterval timeSincePause = [layer convertTime:CACurrentMediaTime() fromLayer:nil] - pausedTime;
layer.beginTime = timeSincePause;
}
Translate
2013年7月11日 星期四
讓UIView或UIScrollView的動畫暫停跟繼續動畫
2013年7月8日 星期一
2013年7月1日 星期一
iPad willAnimateRotationToInterfaceOrientation
這幾天再寫個ipad專案
發現有時候willAnimateRotationToInterfaceOrientation沒有被呼叫到
所以上網查了一下資料
參考link
This is expected behavior as I see it. If the UIVC is not on the top of the stack, then willAnimateRotationToInterfaceOrientation shouldn't be called as no rotation is being animated at that time. The way I've been handling this in the app I am working on now is similar to the above poster. Any UIVC that supports all orientations gets a new method
- (void) updateLayoutForNewOrientation: (UIInterfaceOrientation) orientation;
This method is called from two places:
The new method is simple:
發現有時候willAnimateRotationToInterfaceOrientation沒有被呼叫到
所以上網查了一下資料
參考link
This is expected behavior as I see it. If the UIVC is not on the top of the stack, then willAnimateRotationToInterfaceOrientation shouldn't be called as no rotation is being animated at that time. The way I've been handling this in the app I am working on now is similar to the above poster. Any UIVC that supports all orientations gets a new method
- (void) updateLayoutForNewOrientation: (UIInterfaceOrientation) orientation;
This method is called from two places:
-(void) viewWillAppear: (BOOL) animated {
[super viewWillAppear: animated];
[self updateLayoutForNewOrientation: self.interfaceOrientation];
}
-(void) willAnimateRotationToInterfaceOrientation: (UIInterfaceOrientation) interfaceOrientation duration: (NSTimeInterval) duration {
[self updateLayoutForNewOrientation: interfaceOrientation];
}
The new method is simple:
- (void) updateLayoutForNewOrientation: (UIInterfaceOrientation) orientation {
if (UIInterfaceOrientationIsLandscape(orientation)) {
// Do some stuff
} else {
// Do some other stuff
}
}
訂閱:
文章 (Atom)