您的位置:首页 > 移动开发 > IOS开发

iOS动画 对号和叉叉

2017-05-19 11:20 357 查看
一个很好玩的动画,分享给大家:





  很方便的调用方法:

- (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
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息