标签:property 16px UI lin atom 注意事项 ace view orm
1.动画效果实现难度的推断
2.将看到的动画效果拆分成小模块
3.将写好的小模块组合成你所须要的动画效果
一,新建一个BaseAnimationView主控类
@interface BaseAnimationView :UIView
- (void)show;
- (void)hide;
- (void)buildView;
@end
#import "BaseAnimationView.h"
#import "CircleView.h"
#import "LineView.h"
@interface BaseAnimationView ()
@property (nonatomic,strong) CircleView *circleView;
@property (nonatomic,strong) RectView *lineView;
@end
@implementation BaseAnimationView
- (void)show {
[self.circleViewshow];
[self.lineViewshow];
}
- (void)hide {
[self.circleViewhide];
[self.lineViewhide];
}
- (void)buildView {
self.circleView = [[CircleViewalloc] initWithFrame:CGRectZero];
[selfaddSubview:self.circleView];
self.lineView = [[RectViewalloc] initWithFrame:CGRectZero];
[selfaddSubview:self.lineView];
}
@end
二、新建CircleView,LineView类。方法名都统一,此两类被BaseAnimationView控制
@interface CircleView :UIView
- (void)show;
- (void)hide;
- (void)buildView;
@end
#import "CircleView.h"
@implementation CircleView
- (void)show {}
- (void)hide {}
- (void)buildView {}
@end
@interface LineView : UIView
- (void)show;
- (void)hide;
- (void)buildView;
@end
#import "LineView.h"
@implementation LineView
- (void)show {}
- (void)hide {}
- (void)buildView {}
@end
三、使用复杂的动画被写进了BaseAnimationView其中。没有暴露不必要的细节,便于维持
- (void)viewDidLoad {
[superviewDidLoad];
// 复杂的动画被写进了BaseAnimationView其中,没有暴露不必要的细节
BaseAnimationView *baseView = [[BaseAnimationViewalloc] initWithFrame:CGRectZero];
[self.viewaddSubview:baseView];
[baseViewshow];
}
四、总结
1.制定统一的动画接口
2.动画中的高内聚低耦合原理
3.设计动画函数的注意事项
4.用里氏代换原则来处理动画类的继承问题
5.动画中的模块化设计
标签:property 16px UI lin atom 注意事项 ace view orm
原文地址:http://www.cnblogs.com/brucemengbm/p/7141746.html