skip to content
this repository
explore
gist
blog
help
@baishiyun baishiyun
1
3
0
baishiyun/viewcontrolleranimation
viewcontrolleranimation/viewcontrolleranimation/viewcontroller.m
@baishiyun baishiyun 28 minutes ago 自定义push转场动画
1 contributor
72 lines (60 sloc) 2.616 kb
//
// viewcontroller.m
// viewcontrolleranimation
//
// created by mac on 15/5/26.
// 尊龙凯时 copyright (c) 2015年 bsy. all rights reserved.
//
#import "viewcontroller.h"
#import "twoviewcontroller.h"
@interface viewcontroller ()
@property(nonatomic,strong)twoviewcontroller*two;
@property(nonatomic,strong)uiviewcontroller *currentviewcontroller;;
@end
@implementation viewcontroller
- (void)viewdidload {
[super viewdidload];
self.title = @"第一页";
self.view.backgroundcolor = [uicolor graycolor];
self.animator = [[bsyanimator alloc]init];
self.transitionanimator = [[bsytransitionanimator alloc]init];
uibutton *button = [uibutton buttonwithtype: uibuttontypecustom];
[button setframe:cgrectmake(100, 100, 100, 100)];
[button settitle:@"push" forstate:uicontrolstatenormal];
[button settitlecolor:[uicolor blackcolor] forstate:uicontrolstatenormal];
[self.view addsubview:button];
[button addtarget:self action:@selector(buttonclick) forcontrolevents:uicontroleventtouchupinside];
twoviewcontroller *two = [[twoviewcontroller alloc]init];
self.two = two;
self.navigationcontroller.delegate = self;
two.transitioningdelegate = self;
two.modalpresentationstyle = uimodalpresentationcustom;
[self addchildviewcontroller:two];
self.currentviewcontroller = two;
}
-(void)buttonclick
{
[self.navigationcontroller pushviewcontroller:self.two animated:yes];
}
#pragma mark - uinavigationcontrollerdelegate ios7新增的2个方法
// 动画特效
- (id) navigationcontroller:(uinavigationcontroller *)navigationcontroller animationcontrollerforoperation:(uinavigationcontrolleroperation)operation fromviewcontroller:(uiviewcontroller *)fromvc toviewcontroller:(uiviewcontroller *)tovc
{
if (operation == uinavigationcontrolleroperationpush) {
return self.animator;
}else{
return nil;
}
}
#pragma mark - transitioning delegate (modal)
-(id)animationcontrollerforpresentedcontroller:(uiviewcontroller *)presented presentingcontroller:(uiviewcontroller *)presenting sourcecontroller:(uiviewcontroller *)source
{
self.transitionanimator.animationtype = animationtypepresent;
return self.transitionanimator;
}
-(id)animationcontrollerfordismissedcontroller:(uiviewcontroller *)dismissed
{
self.transitionanimator.animationtype = animationtypedismiss;
return self.transitionanimator;
}
@end
status api training shop blog about
? 2015 github, inc. terms privacy security contact
用户登录
还没有账号?立即注册
用户注册
投稿取消
| 文章分类: |
|
还能输入300字
上传中....
月城泪远