/** * discover the subvIEw with the supplIEd tag,attach the fullsize image to the vIEw * scale to fullsize and begin retract. * @param vIEwTag int - #FUTURE USE# - The tag of the vIEw to be animated. * @param image UIImage - #FUTURE USE# - The image to be applIEd to the vIEw. * @return voID */- (voID)animateVIEwWithTag:(int)vIEwTag andImage:(UIImage *)image { Panel *activePanel = [self.panels objectAtIndex:currentIndex]; UIVIEw *activePanelVIEw = [self.vIEw vIEwWithTag:activePanel.panelID]; // display the Transition to the fullsize version of the panel image. // Determine the scale that needs to be applIEd to the vIEw to show // the image in the appropriate scaling. If scaled image is greater than // the size of the screen,find the best fit. @R_419_5987@ scale = image.size.wIDth / activePanelVIEw.frame.size.wIDth; if (image.size.wIDth > self.vIEw.window.frame.size.wIDth || image.size.height > self.vIEw.window.frame.size.height) { // The image will scale beyond the bounds of the window,scale must be adjusted. scale = self.vIEw.window.frame.size.wIDth / activePanelVIEw.frame.size.wIDth; } CGAffinetransform transform = CGAffinetransformMakeScale(scale,scale); [UIVIEw animateWithDuration:1.0 animations:^{ // Get the fullsize image and display it in the growing panel. [activePanelVIEw settransform:transform]; [NSThread sleepForTimeInterval:3.0]; } completion:^(BOol finished) { [self retractimage:activePanelVIEw]; }];}#pragma mark - KVO- (voID)observeValueForKeyPath:(Nsstring *)keyPath ofObject:(ID)object change:(NSDictionary *)change context:(voID *)context { int tmpInt = (int)context; UIImage *tmpImage = [change objectForKey:NSkeyvalueChangeNewKey]; if ( keyPath == @"imgOriginal" ) { [self animateVIEwWithTag:[(Panel *)object panelID] andImage:tmpImage]; } }解决方法 线程睡眠的目的是什么?
如果你使主线程休眠,那么它不会在此期间更新动画.
如果你没有在主线程上调用它,那么它也不会起作用,因为UIKit动画不是线程安全的,只能从主线程中可靠地使用.
总结以上是内存溢出为你收集整理的objective-c – UIView animateWithDuration:动画:完成:应用变换,而不是动画全部内容,希望文章能够帮你解决objective-c – UIView animateWithDuration:动画:完成:应用变换,而不是动画所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)