{"id":63,"date":"2013-02-18T17:02:18","date_gmt":"2013-02-18T09:02:18","guid":{"rendered":"http:\/\/sunyuping.cn\/?p=63"},"modified":"2013-02-18T17:02:18","modified_gmt":"2013-02-18T09:02:18","slug":"ios%e5%b8%b8%e7%94%a8%e7%9a%84%e5%87%a0%e4%b8%aa%e5%8a%a8%e7%94%bb%e4%bb%a3%e7%a0%81","status":"publish","type":"post","link":"https:\/\/www.sunyuping.com\/index.php\/2013\/02\/18\/ios%e5%b8%b8%e7%94%a8%e7%9a%84%e5%87%a0%e4%b8%aa%e5%8a%a8%e7%94%bb%e4%bb%a3%e7%a0%81\/","title":{"rendered":"ios\u5e38\u7528\u7684\u51e0\u4e2a\u52a8\u753b\u4ee3\u7801"},"content":{"rendered":"<p>\t\t\t\t\u4f7f\u7528\u524d<br \/>\n\u9700\u5f15\u5165QuartzCore.framework, \u5e76\u5728\u76f8\u5173\u6587\u4ef6\u4e2d\u52a0\u5165 #import &#8220;QuartzCore\/QuartzCore.h&#8221;<\/p>\n<p>\u5b9a\u4e49<\/p>\n<p>shakeFeedbackOverlay\u4e3aUIImageView<\/p>\n<p>\u8bbe\u7f6e<\/p>\n<p>self.shakeFeedbackOverlay.alpha = 0.0;<\/p>\n<p>self.shakeFeedbackOverlay.layer.cornerRadius = 10.0; \/\/\u8bbe\u7f6e\u5706\u89d2\u534a\u5f84<\/p>\n<p>1\u3001\u56fe\u50cf\u5de6\u53f3\u6296\u52a8<\/p>\n<p>CABasicAnimation* shake = [CABasicAnimation animationWithKeyPath:@&#8221;transform.rotation.z&#8221;];<\/p>\n<p>shake.fromValue = [NSNumber numberWithFloat:-M_PI\/32];<\/p>\n<p>shake.toValue = [NSNumber numberWithFloat:+M_PI\/32];<\/p>\n<p>shake.duration = 0.1;<\/p>\n<p>shake.autoreverses = YES; \/\/\u662f\u5426\u91cd\u590d<\/p>\n<p>shake.repeatCount = 4;<\/p>\n<p>[self.shakeFeedbackOverlay.layer addAnimation:shake forKey:@&#8221;shakeAnimation&#8221;];<\/p>\n<p>self.shakeFeedbackOverlay.alpha = 1.0;<\/p>\n<p>[UIView animateWithDuration:2.0 delay:0.0 options:UIViewAnimationOptionCurveEaseIn | UIViewAnimationOptionAllowUserInteraction animations:^{ self.shakeFeedbackOverlay.alpha = 0.0; \/\/\u900f\u660e\u5ea6\u53d80\u5219\u6d88\u5931 } completion:nil];<\/p>\n<p>2\u3001\u56fe\u50cf\u987a\u65f6\u9488\u65cb\u8f6c<\/p>\n<p>CABasicAnimation* shake = [CABasicAnimation animationWithKeyPath:@&#8221;transform.rotation.z&#8221;];<\/p>\n<p>shake.fromValue = [NSNumber numberWithFloat:0];<\/p>\n<p>shake.toValue = [NSNumber numberWithFloat:2*M_PI];<\/p>\n<p>shake.duration = 0.8; shake.autoreverses = NO;<\/p>\n<p>shake.repeatCount = 1;<\/p>\n<p>[self.shakeFeedbackOverlay.layer addAnimation:shake forKey:@&#8221;shakeAnimation&#8221;];<\/p>\n<p>self.shakeFeedbackOverlay.alpha = 1.0;<\/p>\n<p>[UIView animateWithDuration:10.0 delay:0.0 options:UIViewAnimationOptionCurveEaseIn | UIViewAnimationOptionAllowUserInteraction animations:^{ self.shakeFeedbackOverlay.alpha = 0.0; } completion:nil];<\/p>\n<p>3\u3001\u56fe\u50cf\u5173\u952e\u5e27\u52a8\u753b<\/p>\n<p>CAKeyframeAnimation *animation = [CAKeyframeAnimation animation];<\/p>\n<p>CGMutablePathRef aPath = CGPathCreateMutable();<\/p>\n<p>CGPathMoveToPoint(aPath, nil, 20, 20);<\/p>\n<p>CGPathAddCurveToPoint(aPath, nil, 160, 30, 220, 220, 240, 420);<\/p>\n<p>animation.path = aPath;<\/p>\n<p>animation.autoreverses = YES;<\/p>\n<p>animation.duration = 2;<\/p>\n<p>animation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseOut];<\/p>\n<p>animation.rotationMode = @&#8221;auto&#8221;;<\/p>\n<p>[ballView.layer addAnimation:animation forKey:@&#8221;position&#8221;];<\/p>\n<p>4\u3001\u7ec4\u5408\u52a8\u753b CAAnimationGroup<\/p>\n<p>CABasicAnimation *flip = [CABasicAnimation animationWithKeyPath:@&#8221;transform.rotation.y&#8221;];<\/p>\n<p>flip.toValue = [NSNumbernumberWithDouble:-M_PI];<\/p>\n<p>&nbsp;<\/p>\n<p>CABasicAnimation *scale= [CABasicAnimation animationWithKeyPath:@&#8221;transform.scale&#8221;];<\/p>\n<p>scale.toValue = [NSNumbernumberWithDouble:12];<\/p>\n<p>scale.duration = 1.5;<\/p>\n<p>scale.autoreverses = YES;<\/p>\n<p>&nbsp;<\/p>\n<p>CAAnimationGroup *group = [CAAnimationGroup animation];<\/p>\n<p>group.animations = [NSArray arrayWithObjects:flip, scale, nil];<\/p>\n<p>group.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];<\/p>\n<p>group.duration = 3;<\/p>\n<p>group.fillMode = kCAFillModeForwards;<\/p>\n<p>group.removedOnCompletion = NO;<\/p>\n<p>[ballView.layer addAnimation:group forKey:@&#8221;position&#8221;];<\/p>\n<p>5\u3001\u6307\u5b9a\u65f6\u95f4\u5185\u65cb\u8f6c\u56fe\u7247<\/p>\n<p>\/\/\u542f\u52a8\u5b9a\u65f6\u5668\u65cb\u8f6c\u5149\u5708<\/p>\n<p>&#8211; (void)startRotate<\/p>\n<p>{<\/p>\n<p>self.rotateTimer = [NSTimer scheduledTimerWithTimeInterval:0.02<\/p>\n<p>target:self<\/p>\n<p>selector:@selector(rotateGraduation)<\/p>\n<p>userInfo:nil<\/p>\n<p>repeats:YES];<\/p>\n<p>}<\/p>\n<p>\/\/\u5173\u95ed\u5b9a\u65f6\u5668<\/p>\n<p>&#8211; (void)stopTimer<\/p>\n<p>{<\/p>\n<p>if ([self.rotateTimerisValid])<\/p>\n<p>{<\/p>\n<p>[self.rotateTimerinvalidate];<\/p>\n<p>self.rotateTimer = nil;<\/p>\n<p>}<\/p>\n<p>}<\/p>\n<p>&nbsp;<\/p>\n<p>\/\/\u65cb\u8f6c\u52a8\u753b<\/p>\n<p>&#8211; (void)rotateGraduation<\/p>\n<p>{<\/p>\n<p>self.timeCount&#8211;;<\/p>\n<p>if (self.timeCount == 0)<\/p>\n<p>{<\/p>\n<p>[self stopTimer];<\/p>\n<p>\/\/ doSomeThing \/\/\u65cb\u8f6c\u5b8c\u6bd5 \u53ef\u4ee5\u5e72\u70b9\u522b\u7684<\/p>\n<p>self.timeCount = 25;<\/p>\n<p>}<\/p>\n<p>else<\/p>\n<p>{<\/p>\n<p>\/\/\u8ba1\u7b97\u89d2\u5ea6 \u65cb\u8f6c<\/p>\n<p>static CGFloat radian = 150 * (M_2_PI \/ 360);<\/p>\n<p>CGAffineTransform transformTmp = self.lightImageView.transform;<\/p>\n<p>transformTmp = CGAffineTransformRotate(transformTmp, radian);<\/p>\n<p>self.lightImageView.transform = transformTmp;<\/p>\n<p>};<\/p>\n<p>}<\/p>\n<p>\u8c03\u7528\u65b9\u6cd5<\/p>\n<p>self.timeCount = 25; \/\/\u52a8\u753b\u6267\u884c25\u6b21<\/p>\n<p>[self startRotate];\t\t<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u4f7f\u7528\u524d \u9700\u5f15\u5165QuartzCore.framework, \u5e76\u5728\u76f8\u5173\u6587\u4ef6\u4e2d\u52a0\u5165 #import &#8220;Q &#8230; <a title=\"ios\u5e38\u7528\u7684\u51e0\u4e2a\u52a8\u753b\u4ee3\u7801\" class=\"read-more\" href=\"https:\/\/www.sunyuping.com\/index.php\/2013\/02\/18\/ios%e5%b8%b8%e7%94%a8%e7%9a%84%e5%87%a0%e4%b8%aa%e5%8a%a8%e7%94%bb%e4%bb%a3%e7%a0%81\/\" aria-label=\"\u9605\u8bfb ios\u5e38\u7528\u7684\u51e0\u4e2a\u52a8\u753b\u4ee3\u7801\">\u9605\u8bfb\u66f4\u591a<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2],"tags":[],"class_list":["post-63","post","type-post","status-publish","format-standard","hentry","category-2"],"_links":{"self":[{"href":"https:\/\/www.sunyuping.com\/index.php\/wp-json\/wp\/v2\/posts\/63","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.sunyuping.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.sunyuping.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.sunyuping.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.sunyuping.com\/index.php\/wp-json\/wp\/v2\/comments?post=63"}],"version-history":[{"count":0,"href":"https:\/\/www.sunyuping.com\/index.php\/wp-json\/wp\/v2\/posts\/63\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.sunyuping.com\/index.php\/wp-json\/wp\/v2\/media?parent=63"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.sunyuping.com\/index.php\/wp-json\/wp\/v2\/categories?post=63"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.sunyuping.com\/index.php\/wp-json\/wp\/v2\/tags?post=63"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}