iOS動畫 對號和叉叉

一個很好玩的動畫,分享給大家:

這裏寫圖片描述

這裏寫圖片描述


  很方便的調用方法:

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.

    self.checkView = [[SHCheckInfoView alloc] initWithFrame:CGRectMake(0, 0, 40, 40) lineWidth:2 lineColor:[UIColor redColor]];
    self.checkView.center = self.view.center;
    [self.view addSubview:self.checkView];
}

- (IBAction)onRightBtnAction:(id)sender {
    [self.checkView showAnimationWithState:XYProgressResult_Success duration:1.5 complete:nil];
}
- (IBAction)onFailedBtnAction:(id)sender {
    [self.checkView showAnimationWithState:XYProgressResult_Failed duration:1.5 complete:nil];
}


  SHCheckInfoView頭文件接口:

#import <UIKit/UIKit.h>

// 設置動畫效果樣式
typedef enum{
    XYProgressResult_Success,
    XYProgressResult_Failed,
}XYProgressResultState;

@interface SHCheckInfoView : UIView

// 線條寬度,默認爲3.0;
@property (nonatomic, assign) CGFloat lineWidth;

// 線條顏色,默認是redColor
@property (nonatomic, strong) UIColor *lineColor;

// 設置填充顏色,默認是clearColor;
@property (nonatomic, strong) UIColor *fillColor;

- (instancetype)initWithFrame:(CGRect)frame lineWidth:(CGFloat)lineWidth lineColor:(UIColor *)lineColor;

/*
 *  state 成功或者失敗狀態,決定繪畫樣式。
 *  duration 動畫時長。
 *  complate 動畫結束時回調。
 */
- (void)showAnimationWithState:(XYProgressResultState)state duration:(NSTimeInterval)duration complete:(void (^) (BOOL isFinish))complate;

@end



代碼GitHub地址:https://github.com/lvshaohua/SHCheckInfoView

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章