目前动画只支持UIView的几个简单的animate,是通过扩展的方式接入的,直接上代码:
1:接入代码
- (instancetype)init { if (self = [super init]) { _viewControllers = [NSMapTable strongToWeakObjectsMapTable]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(njcsViewControllerDealloc:) name:NJCSVIEWCONTROLLER_DEALLOC object:nil]; _njcsJSContext = [[NJCS_JSContext alloc] init]; _njcsJSContext.jscontext[@"NJCSBridge_Native"] = self; self.macors = [[NJCSMacors alloc] init]; self.njcsHttp = [[NJCSHttp alloc] init]; self.viewAnimate = [[NJCSViewAnimate alloc] init]; self.modelAdapter = [[NJCSModelAdapter alloc] init]; self.notifyManager = [NJCSNotificationManager sharedManager]; self.njcsAlert = [NJCSAlert shareInstance]; } return self; }
viewAnimate是做为必接扩展添加进去的,是用户必须实现的。
对外公开的几个方法如下:
- (void)animateWithDuration:(NSTimeInterval)duration animations:(void (^ _Nullable)(void))animations { [UIView animateWithDuration:duration animations:animations]; } - (void)animateWithDuration:(NSTimeInterval)duration animations:(void (^ _Nullable)(void))animations completion:(void (^ _Nullable)(BOOL))completion { [UIView animateWithDuration:duration animations:animations completion:completion]; } - (void)animateWithDuration:(NSTimeInterval)duration delay:(NSTimeInterval)delay options:(UIViewAnimationOptions)options animations:(void (^ _Nullable)(void))animations completion:(void (^ _Nullable)(BOOL))completion { [UIView animateWithDuration:duration delay:delay options:options animations:animations completion:completion]; }
都是些很简单的实现,这里就不详细介绍了。