The modular design in animation

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.