{"id":15038105,"url":"https://github.com/manofit/babypiganimation","last_synced_at":"2025-10-06T21:12:11.813Z","repository":{"id":51187672,"uuid":"126920700","full_name":"manofit/BabyPigAnimation","owner":"manofit","description":"基本动画、位移动画、缩放动画、旋转动画、组动画、关键帧动画、贝塞尔曲线、进度条动画、复杂动画、OC动画、aniamtion、basicanimation等。","archived":false,"fork":false,"pushed_at":"2018-05-07T08:40:26.000Z","size":6397,"stargazers_count":219,"open_issues_count":1,"forks_count":37,"subscribers_count":0,"default_branch":"master","last_synced_at":"2024-12-19T19:08:15.984Z","etag":null,"topics":["animation","animation-library","animations","demo","ios","ios-app","objective-c","swift","swift4"],"latest_commit_sha":null,"homepage":"","language":"Objective-C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/manofit.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-03-27T03:02:23.000Z","updated_at":"2024-11-01T08:23:23.000Z","dependencies_parsed_at":"2022-08-30T08:30:17.600Z","dependency_job_id":null,"html_url":"https://github.com/manofit/BabyPigAnimation","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/manofit%2FBabyPigAnimation","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/manofit%2FBabyPigAnimation/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/manofit%2FBabyPigAnimation/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/manofit%2FBabyPigAnimation/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/manofit","download_url":"https://codeload.github.com/manofit/BabyPigAnimation/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":230487844,"owners_count":18233865,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["animation","animation-library","animations","demo","ios","ios-app","objective-c","swift","swift4"],"created_at":"2024-09-24T20:37:07.169Z","updated_at":"2025-10-06T21:12:06.742Z","avatar_url":"https://github.com/manofit.png","language":"Objective-C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# BabyPigAnimation\n\n从简单的基础动画到复杂的组动画，原理一目了然。最后再加上几个常见动画，举一反三。\n### 效果图\n![gif_1](https://github.com/manofit/ScreenPics/blob/master/PigAnimation_Pics/gif_1.gif)![gif_2](https://github.com/manofit/ScreenPics/blob/master/PigAnimation_Pics/gif_2.gif)![gif_3](https://github.com/manofit/ScreenPics/blob/master/PigAnimation_Pics/gif_3.gif)![love](https://github.com/manofit/ScreenPics/blob/master/PigAnimation_Pics/love.gif)![progress](https://github.com/manofit/ScreenPics/blob/master/PigAnimation_Pics/progress.gif)\n\n\n### 使用\n- 基础动画\n```\n//位移\n-(void)makePositionAnimation{\n    CABasicAnimation *animation = [CABasicAnimation animationWithKeyPath:@\"position\"];\n    animation.fromValue = [NSValue valueWithCGPoint:CGPointMake(50, SCREEN_HEIGHT/2-75)];\n    animation.toValue = [NSValue valueWithCGPoint:CGPointMake(SCREEN_WIDTH-50, SCREEN_HEIGHT/2-75)];\n    animation.duration = 1.0f;\n    //animation.fillMode = kCAFillModeForwards;\n    //animation.removedOnCompletion = NO;\n    [self.babyView.layer addAnimation:animation forKey:@\"positionAnimation\"];\n}\n```\n- 关键帧动画\n```\nCAKeyframeAnimation *animation = [CAKeyframeAnimation animationWithKeyPath:@\"position\"];\nNSValue *value_0 = [NSValue valueWithCGPoint:CGPointMake(50, SCREEN_HEIGHT/2-50)];\nNSValue *value_1 = [NSValue valueWithCGPoint:CGPointMake(SCREEN_WIDTH/3, SCREEN_HEIGHT/2-50)];\nNSValue *value_2 = [NSValue valueWithCGPoint:CGPointMake(SCREEN_WIDTH/3, SCREEN_HEIGHT/2+50)];\nNSValue *value_3 = [NSValue valueWithCGPoint:CGPointMake(SCREEN_WIDTH*2/3, SCREEN_HEIGHT/2+50)];\nNSValue *value_4 = [NSValue valueWithCGPoint:CGPointMake(SCREEN_WIDTH*2/3, SCREEN_HEIGHT/2-50)];\nNSValue *value_5 = [NSValue valueWithCGPoint:CGPointMake(SCREEN_WIDTH-50, SCREEN_HEIGHT/2-50)];\nanimation.values = [NSArray arrayWithObjects:value_0,value_1,value_2,value_3,value_4,value_5, nil];\nanimation.duration = 2.0f;\n[self.babyView.layer addAnimation:animation forKey:@\"keyFrameAnimation\"];\n```\n- 组动画\n```\nCAKeyframeAnimation *positionAni = [CAKeyframeAnimation animationWithKeyPath:@\"position\"];\nNSValue *value_0 = [NSValue valueWithCGPoint:CGPointMake(50, SCREEN_HEIGHT/2-50)];\nNSValue *value_1 = [NSValue valueWithCGPoint:CGPointMake(SCREEN_WIDTH/3, SCREEN_HEIGHT/2-50)];\nNSValue *value_2 = [NSValue valueWithCGPoint:CGPointMake(SCREEN_WIDTH/3, SCREEN_HEIGHT/2+50)];\nNSValue *value_3 = [NSValue valueWithCGPoint:CGPointMake(SCREEN_WIDTH*2/3, SCREEN_HEIGHT/2+50)];\nNSValue *value_4 = [NSValue valueWithCGPoint:CGPointMake(SCREEN_WIDTH*2/3, SCREEN_HEIGHT/2-50)];\nNSValue *value_5 = [NSValue valueWithCGPoint:CGPointMake(SCREEN_WIDTH-50, SCREEN_HEIGHT/2-50)];\npositionAni.values = [NSArray arrayWithObjects:value_0,value_1,value_2,value_3,value_4,value_5, nil];\n\nCABasicAnimation *scaleAni = [CABasicAnimation animationWithKeyPath:@\"transform.scale\"];\nscaleAni.fromValue = [NSNumber numberWithFloat:0.8f];\nscaleAni.toValue = [NSNumber numberWithFloat:2.0f];\n    \nCABasicAnimation *rotateAni = [CABasicAnimation animationWithKeyPath:@\"transform.rotation\"];\nrotateAni.toValue = [NSNumber numberWithFloat:M_PI*4];\n    \nCAAnimationGroup *groupAni = [CAAnimationGroup animation];\ngroupAni.animations = [NSArray arrayWithObjects:positionAni,scaleAni,rotateAni, nil];\ngroupAni.duration = 4.0f;\n[self.babyView.layer addAnimation:groupAni forKey:@\"groupAnimation\"];\n```\n- 过渡动画\n```\nCATransition *transitionAni = [CATransition animation];\ntransitionAni.type = kCATransitionMoveIn;\ntransitionAni.subtype = kCATransitionFromRight;\ntransitionAni.duration = 1.0f;\n[self.babyView.layer addAnimation:transitionAni forKey:@\"moveInAnimation\"];\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmanofit%2Fbabypiganimation","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmanofit%2Fbabypiganimation","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmanofit%2Fbabypiganimation/lists"}