1. Animation effect to achieve the difficulty of judging2. Split the animation effect you see into a small module3. Combine the small, well-written modules into the animation you need
One, create a new Baseanimationview main control class
@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. Lineview show];
}
-(void) Hide {
[self. Circleviewhide];
[Self. Lineview Hide];
}
-(void) Buildview {
self. Circleview = [[circleviewalloc] initwithframe: Cgrectzero];
[selfaddsubview:self. Circleview];
self. Lineview = [[rectviewalloc] initwithframe:cgrectzero];
[selfaddsubview:self. Lineview];
}
@end
Second, the new Circleview,lineview class, the method is unified, these two categories areBaseanimationview Control
@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
Third, the use of complex animation was written into the Baseanimationview , without exposing unnecessary details, easy to maintain
-(void) Viewdidload {
[superviewdidload];
// complex animations are written into the Baseanimationview , without exposing unnecessary details
baseanimationview *baseview = [[baseanimationviewalloc] initWithFrame:cgrectzero];
[Self. View addsubview: Baseview];
[Baseviewshow];
}
Iv. Summary1. Develop a unified animation interface2. Low coupling principle of high cohesion in animation3. Considerations for designing animation functions4. Using the principle of the Richter substitution to deal with the inheritance problem of animation class5. Modular Design in animation
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
The modular design in animation