iOS动画 对号和叉叉

来源:互联网 发布:海德椭圆机 知乎 编辑:程序博客网 时间:2024/04/28 20:44

一个很好玩的动画,分享给大家:

这里写图片描述

这里写图片描述


  很方便的调用方法:

- (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

原创粉丝点击