@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.circleView show];
[self.lineView show];
}
- (void)hide {
[self.circleView hide];
[self.lineView hide];
}
- (void)buildView {
self.circleView = [[CircleView alloc] initWithFrame:CGRectZero];
[self addSubview:self.circleView];
self.lineView = [[RectView alloc] initWithFrame:CGRectZero];
[self addSubview:self.lineView];
}
@end
@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 {
[super viewDidLoad];
// 复杂的动画被写进了BaseAnimationView当中,没有暴露不必要的细节
BaseAnimationView *baseView = [[BaseAnimationView alloc] initWithFrame:CGRectZero];
[self.view addSubview:baseView];
[baseView show];
}
版权声明:本文为博主原创文章,未经博主允许不得转载。
原文地址:http://blog.csdn.net/baitxaps/article/details/46848345