iOS第三方开源类库 -- 视图切换 HMGLTransitions
HMGLTransitions 是一套动画演示两个UIView 或 UIViewController之间切换时的过渡效果;
GitHub下载地址:https://github.com/Split82/HMGLTransitions
有些情况下我们需要两个视图之间做一个动画过渡的切换,或许系统自带的CATransition和普通动画难以满足我们的需求,此时第三方类库就是一个不错的选择;HMGLTransitions提供五种不错效果,分别是: 3D Right(letf) 、Cloth、Flip right(letf)、Rotate和Doors
以上是GitHub上下载自带的Demo展示的五种效果图,展示了两个UIView 和 两个UIViewController各自之间动画切换(截图中仅展示两个view之间切换),工程目录结构:
HMGLTransitions目录下是这个第三方类库所有文件,Transitions文件下是五种动画的实现类,你需要那种动画就需要把那种动画头文件包含进去
两个UIView之间的动画过渡切换实现方法
1.新建一个Single View Application模板工程,命名RollingView,将下载下来的工程中里HMGLTransitions文件夹拷贝加入到你的工程目录中,然后添加 QuartzCore.framework 和 OpenGLES.framework 库
2. File->New->File 添加一个控制器类ViewController2,在ViewController.h中包含头文件
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil{ self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]; if (self) { FlipTransition *tran = [[[FlipTransition alloc] init] autorelease]; tran.transitionType = FlipTransitionLeft; transitionArr = [[NSArray alloc] initWithObjects:[[[FlipTransition alloc] init] autorelease], nil]; self.transition = [transitionArr objectAtIndex:0]; } return self;}- (void)viewDidLoad{ [super viewDidLoad]; CGRect butRect; if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {butRect = CGRectMake(self.view.bounds.origin.x + 60, self.view.bounds.origin.y + 100, 768-60-60, 100);}else {butRect = CGRectMake(self.view.bounds.origin.x + 60, self.view.bounds.origin.y + 100, self.view.frame.size.width-60-60, 100);} endBtn= [self buttonWithFrame:butRect withNormalTitle:@"View 2" withOtherStateTitle:@"View 2" action:@selector(endView:)];}-(void)endView:(id)sender{ [[HMGLTransitionManager sharedTransitionManager] setTransition:transition]; ViewController *vc1; if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {vc1 = [[ViewController alloc] initWithNibName:@"ViewController_iPad" bundle:nil]; }else {vc1 = [[ViewController alloc] initWithNibName:@"ViewController_iPhone" bundle:nil];} [[HMGLTransitionManager sharedTransitionManager] presentModalViewController:vc1 onViewController:self];}
源码:http://download.csdn.net/detail/duxinfeng2010/5212826
欢迎转载分享,请注明出处http://blog.csdn.net/duxinfeng2010