;@property CGPoint position ֖ᗝ(ἕᦊ೰Ӿᅩٍ֛҅ኧanchorPoint٬ਧ)ғ @property CGRect bounds; ਼ଶ޾ṛଶғ CALayerጱच๜ં௔ ᥡં௔̶ ࢩྌ҅᭗ᬦ᧣ᜓCALayer੒᨝҅ݢզஉො׎ጱ᧣ෆUIViewጱӞԶक़ ᚆ̶ۑ ᚆ҅ฎਙٖ᮱ጱ੶಍ํดᐏۑഘݙᦾ᧔҅UIView๜᫝ӧٍ॓ดᐏጱ ੽଒Ӥ҅ԭฎ੪ਠ౮ԧUIViewጱดᐏ̶کᨬ ࣁᛔ૩ጱࢶ੶Ӥ҅ᕲࢶਠླݸ҅ᔮᕹտਖ਼ࢶ੶೩ګӬտਖ਼ಅํٖ਻ᕲ ੽଒Ӥ෸҅տ᧣አdrawRect:ොဩᬰᤈᕲࢶ҅ଚک୮UIViewᵱᥝดᐏ @property(nonatomic,readonly,retain) CALayer *layer; ੒᨝)҅᭗ᬦUIViewጱlayerં௔ݢզᦢᳯᬯӻ੶̶ CALayerܨ)ୌӞӻࢶ੶ڠୌUIView੒᨝෸҅UIViewٖ᮱տᛔۖڠࣁ ғ ฎࢩԅਙٖ᮱ጱӞӻࢶ੶قٌਫUIViewԏಅզᚆดᐏࣁ੽଒Ӥ҅ਠ UIView̶ ໛̵Ӟӻࢶຽᒵᒵ҅ᬯԶ᮷ฎفᰵ̵Ӟӻ෈๜ຽᓋ̵Ӟӻ෈๜ᬌ ࣁiOSӾ֦҅ᚆ፡஑ᥠൾ஑፳ጱӳᥜच๜Ӥ᮷ฎUIView҅ྲইӞӻೲ ᔮىCALayerӨUIViewጱ UIView̶ ᥝဳ఺ጱฎ҅Core Animationฎፗള֢አࣁCALayerӤጱ҅ଚᶋ Core Animationጱۖኮಗᤈᬦᑕ᮷ฎࣁݸݣ඙֢ጱ҅ӧտᴥलԆᕚᑕ̶ Core AnimationݢզአࣁMac OS X޾iOSଘݣ̶ ᚆ̶ۑ᧔ֵ҅አ੝ᰁጱդᎱ੪ݢզਫሿᶋଉ୩य़ጱ ׭̶Ԟ੪ฎۑᶋଉᅠԇጱۖኮපຎ҅ᘒӬஃஃฎԪ܎ڊAPIֵ҅አਙᚆ؉ Core Animation҅Ӿ෈ᘉᦲԅ໐ஞۖኮ҅ਙฎӞᕟᶋଉ୩य़ጱۖኮ॒ቘ Collection/Bookmark/Share for width under 768px ਁහ3175 ᴅ᧛9406 ᦧᦞ7 ࡅཻ79 Animation(໐ஞۖኮ) चᏐᎣᦩғCoreݎiOS୏ ̶ړԏӞጱ᮱ړࢥکտ፡ ԅᆿ੶ጱૢӤᅩ҅ᮎԍᧆ੶ࣁᆿ੶Ӿݝܨpositionᦡᗝԅҁ0҅0҂ Ӿᅩҁ0.5҅0.5҂҅ᘒᧆ੶ጱܨ؀ইᲚᅩanchorPointԅἕᦊ؃ ᔮԈֺғىanchorPoint޾positionጱ ԅӾஞᅩҁ0.5, 0.5҂؀᝜ࢱ᮷ฎ0~1҅ἕᦊ؀ਙጱx̵yݐ զᛔ૩ጱૢӤ᥯ԅܻᅩ(0, 0)҅ ٬ਧ፳CALayer᫝Ӥጱߺӻᅩտࣁpositionં௔ಅ೰ጱ֖ᗝ̶ ҅”ᑍԅ“ਧ֖ᅩ”̵“Ლᅩ @property CGPoint anchorPoint;ғ զᆿ੶ጱૢӤ᥯ԅܻᅩ(0, 0) አ๶ᦡᗝCALayerࣁᆿ੶Ӿጱ֖ᗝ @property CGPoint position;ғ position޾anchorPointጱ֢አ @property CATransform3D transform; ୵ݒં௔ғ @property CGColorRef backgroundColor; ᙧว᷏ᜋ(CGColorRefᔄࣳ)ғ @property CGPoint anchorPoint; Ԏғތ٬ਧԧpositionጱ҅(Ლᅩ(x,yጱ᝜ࢱ᮷ฎ0-1 ኞᖽනۖኮ දᬯӻં௔տԾץ•boundsғአԭᦡᗝCALayerጱ਼ଶ޾ṛଶ̶ ӻݢۖኮં௔ғپଉᥠጱ ኮපຎ҅ᘒᬯԶં௔ᑍԅAnimatable Properties(ݢۖኮં௔)̶ ද෸҅ἕᦊտᛔۖԾኞӞԶۖץ௔ᬰᤈંړ୮੒ᶋRoot Layerጱ᮱ ࣁ፳ᵌୗۖኮ ୌጱCALayer੒᨝҅᮷ਂڠ• ಅํጱᶋRoot Layer҅Ԟ੪ฎಋۖ ӻLayerԅRoot Layerҁ໑੶҂ ᘶ፳ӞӻCALayer҅౯ժݢአᑍᬯى• ྯӞӻUIViewٖ᮱᮷ἕᦊ ໑੶Өᶋ໑੶ғ ᵌୗۖኮ anchorPoint޾position Core Animationᕮ຅ ੒ଫጱ໛ຝQuartzCore/QuartzCore.h̶ف޾୚ QuartzCore.frameworkےႲضইຎӧฎxcode5ԏݸጱᇇ๜ֵ҅አਙᵱᥝ UIColor҅ݝᚆֵአCGImageRef̵CGColorRef̶ ᦤݢᑏ༙௔҅QuartzCoreӧᚆֵአUIImage̵כಅզ҅ԅԧ ֕ฎUIKitݝᚆࣁiOSӾֵአ̶ ࣁiOS޾Mac OS XӤ᮷ᚆֵአ ٌེ҅QuartzCore໛ຝ޾CoreGraphics໛ຝฎݢզ᪜ଘݣֵአጱ҅ ҅ᘒUIColor޾UIImageฎਧԎࣁUIKit໛ຝӾጱ̶ CGColorRefӷᐿහഝᔄࣳฎਧԎࣁCoreGraphics໛ຝӾጱ CALayerฎਧԎࣁQuartzCore໛ຝӾጱ҅CGImageRef̵҅ضḒ layer.backgroundColor = [UIColor redColor].CGColor; ԅՋԍCALayerӧᚆፗളֵአUIColor҅UIImageҘ ᕆ̶ ᫷ᰁےᚆ҅ๅۑᆐ҅CALayerጱ௔ᚆտṛӞԶ҅ࢩԅਙ੝ԧԪկ॒ቘጱ ইຎӧᵱᥝ᪙አಁᬰᤈԻ԰҅አUIView౲ᘏCALayer᮷ݢզ̶୮ ๶ጱӳᥜᵱᥝ᪙አಁᬰᤈԻ԰ጱᦾ҅አUIViewҔڊಅզ҅ইຎดᐏ CALayerӧᚆ॒ቘአಁጱ᥶ൾԪկ҅ᘒUIViewݢզ ᚆ̶Ԟ੪ฎ᧔҅ۑٌਫ҅੒ྲCALayer҅UIViewग़ԧӞӻԪկ॒ቘጱ অޫҘ ෬ᆐCALayer޾UIView᮷ᚆਫሿፘݶጱดᐏපຎ҅ᮎᑪᒌᧆᭌೠ᧡ ᪙UIImageViewӞ໏ጱኴᶎපຎ̶ڊ᭗ᬦCALayer҅੪ᚆ؉ UIView޾CALayerጱᭌೠ [CATransaction commit]; self.myview.layer.position = CGPointMake(10, 10); [CATransaction setDisableActions:YES]; ᳮᵌୗۖኮى // ;[[CATransaction begin ᳮᵌୗۖኮғىۓݢզ᭗ᬦԪ ᑏۖኮ දᬯӻં௔տԾኞଘץ•positionғአԭᦡᗝCALayerጱ֖ᗝ̶ ௔տԾኞᙧวᜋጱႹݒۖኮ දᬯӻંץbackgroundColorғአԭᦡᗝCALayerጱᙧวᜋ̶• ... ;[CALayer *layer = [CALayer layer CALayer੒᨝Ӿ੪ݢզ୏তۖኮԧ̶کے• ਖ਼च๜ۖኮ੒᨝Ⴒ ጱં௔̶ىত۸ӞӻCABasicAnimation੒᨝҅ᕳ੒᨝ᦡᗝፘڡ • ᥝํCALayerࢶ੶̶ض • :զच๜ۖኮԅֺ च๜ֵአ CAKeyframeAnimation଄ۖኮ҅؉ӞԶᬳᖅጱၞ኱ጱۖኮ̶ පຎ̶ܔCABasicAnimationच๜ۖኮ҅؉ӞԶᓌ CABasicAnimation޾CAKeyframeAnimationғ ৼᔄ಍ํ̶ CAPropertyAnimationԞฎӻು᨝ᔄ҅๜᫝ӧٍ॓ۖኮපຎ҅ݝํ ኮ̶ ഘ҂᮷ݢզአ᫨࣋ۖڔCATransitionฎ᫨࣋ۖኮ҅ኴᶎԏᳵ᪡᫨ҁ ᬰᤈग़ӻۖኮ҂̶ CAAnimationGroupฎӻۖኮᕟ҅ݢզݶ෸ᬰᤈᖽන҅෤᫨ҁݶ෸ CAAnimationGroup޾CATransition಍ํۖኮපຎ҅ ۖኮපຎ̶ CAAnaimationฎӻು᨝ᔄ҅ӧٍ॓ۖኮපຎ҅஠ᶳአਙጱৼᔄ಍ํ ᦓ̶ܐ໐ஞۖኮӾಅํᔄ᮷᭽ਝCAMediaTiming ᦓ̶ܐᔮ҅ᕁᜋᤒᐏ᭽ਝىٌӾᅍᜋᡦᕚᤒᐏᖀಥ ᔮىᖀಥ fillModeં௔ጱᦡᗝғ ۖኮդቘ delegate ኮᬩᤈጱᜓॵۖګහ҅ഴڍګ᭛ଶഴ timingFunction ෸ᳵڹ CACurrentMediaTime()+2҅CACurrentMediaTime()ԅࢶ੶ጱ୮ ݢզአ๶ᦡᗝۖኮ୊᬴ಗᤈ෸ᳵ҅ᝑమ୊᬴2s҅੪ᦡᗝԅ beginTime ᕮ๳ԏ ౲ᘏۖኮڹ੒᨝ࣁᶋactive෸ᳵྦྷጱᤈԅ̶ྲইۖኮ୏তԏڹ٬ਧ୮ fillMode ᗝԅNO҅ӧᬦᬮᥝᦡᗝfillModeԅkCAFillModeForwards ೮ดᐏۖኮಗᤈݸጱᇫா҅ᮎ੪ᦡכጱᇫா̶ইຎమᦏࢶ੶ڹኮಗᤈ ۖکἕᦊԅYES҅դᤒۖኮಗᤈਠླݸ੪՗ࢶ੶Ӥᑏᴻ҅ࢶ୵տ௩॔ removedOnCompletion ᯿॔෸ᳵ repeatDuration ᯿ེ॔හ҅෫ᴴ஗ሾݢզᦡᗝHUGE_VALF౲ᘏMAXFLOAT repeatCount ۖኮጱ೮ᖅ෸ᳵ duration ᧔ก ં௔ च๜ં௔᧔กғ ᔄ҅ӧᚆፗളֵአ҅ଫᧆֵአਙٍ֛ጱৼᔄ̶ ኮጱ೮ᖅ෸ᳵ޾᭛ଶ҅ฎӻು᨝ۖګฎಅํۖኮ੒᨝ጱᆿᔄ҅ᨮᨱഴ CAAnimation——ᓌՕ [layer addAnimation:animation forKey:nil]; anmation.toValue = @0; anmation.keyPath = @"transform.scale"; CABasicAnimation *animation = [CABasicAnimation animation]; CALayerӤۖኮጱฮ؊޾௩॔ @end - (void)animationDidStop:(CAAnimation *)anim finished:(BOOL)flag; // ۖኮᕮ๳ݸ᧣አ * without being removed. */ * is true if the animation reached the end of its active duration 'flag' * is removed from the object it is attached to (i.e. the layer). or /* Called when the animation either completes its active duration - (void)animationDidStart:(CAAnimation *)anim; // ۖኮ୏ত෸᧣አ /* Called when the animation begins its active duration. */ @interface NSObject (CAAnimationDelegate) ᔄӾਧԎԧդቘොဩړCAAnimationࣁ ᦊጱۖኮᤈԅ̶ ᬡፓጱࣈ̶ᬯӻฎἕک᭛ጱٺ᭛҅ᆐݸےӾᳵ҅فኮᖨౌጱᬰ ҂ғۖڊ•kCAMediaTimingFunctionEaseInEaseOutҁႹᬰႹ ᬡፓጱࣈک᭛ጱٺᆐݸ҅ف ᭛ᬰق҂ғۖኮڊ•kCAMediaTimingFunctionEaseOutҁႹ ᭛ᐶ୏ےᆐݸ ҅ف•kCAMediaTimingFunctionEaseInҁႹᬰ҂ғۖኮᖨౌᬰ ፘ੒ᶉாጱఽᥧ •kCAMediaTimingFunctionLinearҁᕚ௔҂ғ۰᭛҅ᕳ֦Ӟӻ හ(CAMediaTimingFunction)ғڍګ᭛ଶഴ ๋ݸጱᇫா ೮ۖኮכতᇫா҅ۖኮᕮ๳ݸlayerڡlayer׎॒ԭۖኮ҅ڹতԏ ݸ୏فے• kCAFillModeBoth ᬯӻٌਫ੪ฎӤᶎӷӻጱݳ౮.ۖኮ তᇫாଚᒵஇۖኮ୏ত̶ڡኮጱۖفᬰܨӞӻlayer҅layer׎ᒈ ԧفےݝᵱᥝਖ਼ۖኮ҅ڹ•kCAFillModeBackwards ࣁۖኮ୏ত ኮ๋ݸጱᇫா ೮፳ۖכ•kCAFillModeForwards ୮ۖኮᕮ๳ݸ҅layerտӞፗ ጱᇫாڹԏک௩॔ ޾ۖኮᕮ๳ݸ҅ۖኮ੒layer᮷ဌํ୽ߥ҅ۖኮᕮ๳ݸ҅layerտ ڹԞ੪ฎ᧔୮ۖኮ୏ত҅؀kCAFillModeRemoved ᬯӻฎἕᦊ• CABasicAnimation——च๜ۖኮ ଘᑏጱۖኮපຎکզᬡ҅؀ጱ දCALayerጱpositionં௔ץই҅೰ਧ@“position”ԅkeyPath҅੪ ፘଫጱۖኮපຎ̶ྲکද҅ᬡץᬰᤈ؀Ӭ੒CALayerጱᬯӻં௔ጱ ᭗ᬦ೰ਧCALayerጱӞӻં௔ݷᑍԅkeyPathҁNSStringᔄࣳ҂҅ଚ keyPath ᧔ก ં௔ च๜ં௔᧔กғ CAKeyframeAnimation̶ ֵአਙጱӷӻৼᔄғCABasicAnimation޾ ୌۖኮ੒᨝҅ଫᧆڠฎCAAnimationጱৼᔄ҅Ԟฎӻು᨝ᔄ҅ᥝమ CAPropertyAnimation } layer.beginTime = timeSincePause; // 5. ᦡᗝፘ੒ԭᆿࣖຽᔮጱ୏ত෸ᳵ(ஃݸᭅtimeSincePause) convertTime:CACurrentMediaTime() fromLayer:nil] - pausedTime; CFTimeInterval timeSincePause = [layer // 4. ᦇᓒฮ؊ጱ෸ᳵ(ᬯ᯾ԞݢզአCACurrentMediaTime()-pausedTime) layer.beginTime = 0.0; // 3. ݐၾӤེᦡᗝጱ෸ᳵ layer.timeOffset = 0.0; ڰ // 2. ݐၾӤེᦕ୯ጱ؊ኸ෸ layer.speed = 1.0; // 1. ᦏCALayerጱ෸ᳵᖀᖅᤈᩳ CFTimeInterval pausedTime = layer.timeOffset; { -(void)resumeLayer:(CALayer*)layer #pragma mark ௩॔CALayerጱۖኮ } layer.timeOffset = pausedTime; ڰ // ᦏCALayerጱ෸ᳵ؊ኸࣁpausedTimeᬯӻ෸ layer.speed = 0.0; // ᦏCALayerጱ෸ᳵ؊ྊᩳۖ convertTime:CACurrentMediaTime() fromLayer:nil]; CFTimeInterval pausedTime = [layer { -(void)pauseLayer:(CALayer*)layer pragma mark ฮ؊CALayerጱۖኮ# ᦡᗝԧpath҅ᮎԍvaluesਖ਼ᤩ஺ኼ ᭃᑏ̶ۖpathݝ੒CALayerጱanchorPoint޾position֢᩸አ̶ইຎ ݢզᦡᗝӞӻCGPathRef̵CGMutablePathRef҅ᦏࢶ੶ೲᆙ᪠ஆ᫥ path ଄ Ძى೰ਧጱ෸ᳵҁduration҂ׁེٖ҅ดᐏvaluesහᕟӾጱྯӞӻ Ძ଄”(keyframe)̶ۖኮ੒᨝տࣁى“ᔰᑍԅزNSArray੒᨝̶᯾ᶎጱ values ᧔ก ં௔ ં௔᧔กғ CAKeyframeAnimation Ძ଄ጱىCABasicAnimationݢ፡؉ฎݝํ2 ӻ• ؀ᬯԶහਂכNSArray ҁtoValue҂҅ᘒCAKeyframeAnimationտֵአӞӻ؀හ ݚӞӻکҁfromValue҂ݒ؀•CABasicAnimationݝᚆ՗Ӟӻහ ฎғڦ܄CABasicAnimationጱ Ძ଄ۖኮ҅ԞฎCAPropertyAnimationጱৼᔄ҅Өى Ძ଄ۖኮى——CAKeyframeAnimation ଚဌํ፥ྋᤩදݒ̶҅؀তڡጱڹᬮฎۖኮಗᤈ؀Ӥ҅ࢶ੶ጱં௔ ೮ดᐏۖኮಗᤈݸጱᇫா̶֕ࣁਫᨶכԍࣁۖኮಗᤈਠླݸ҅ࢶ੶տ ইຎfillMode = kCAFillModeForwardsݶ෸removedOnComletion = NO҅ᮎ keyPathٖ਻ฎCALayerጱݢۖኮAnimatableં௔̶ ՗fromValueႹႹࣈݒԅtoValue̶؀௔ጱ ᵋ፳ۖኮጱᬰᤈ҅ࣁᳩଶԅdurationጱ೮ᖅ෸ᳵٖ҅keyPathፘଫં ኮᬦᑕ᧔กғۖ ؀keyPathፘଫં௔ጱᕮ๳ toValue ؀তڡkeyPathፘଫં௔ጱ fromValue ᧔ก ં௔ ௔᧔กғં ᬦჁපຎᦡᗝ (ྲړۖኮᕣᅩ(ࣁෆ֛ۖኮጱጯ endProgress (ྲړۖኮ᩸ᅩ(ࣁෆ֛ۖኮጱጯ startProgress ۖኮᬦଶොݻ subtype ۖኮᬦჁᔄࣳ type ᧔ก ં௔ ં௔᧔กғ ੽଒ጱۖኮපຎ̶فᥤࢶവ ࢏ጱګUINavigationController੪ฎ᭗ᬦCATransitionਫሿԧਖ਼ഴ ຎ੝Ӟᅩ̶ ੽଒ጱۖኮපຎ̶iOSྲMac OS Xጱ᫨࣋ۖኮපف੽଒޾ᑏڊᑏ׀൉ CATransitionฎCAAnimationጱৼᔄ҅አԭ؉᫨࣋ۖኮ҅ᚆड़ԅ੶ CATransition——᫨࣋ۖኮ Ӟᕟۖኮ੒᨝ጱNSArrayਂכአ๶ animations ᧔ก ં௔ ં௔᧔กғ ጱbeginTimeં௔๶ๅදۖኮጱ୏ত෸ᳵ̶ ӥ҅Ӟᕟۖኮ੒᨝ฎݶ෸ᬩᤈጱ҅Ԟݢզ᭗ᬦᦡᗝۖኮ੒᨝٭ἕᦊఘ ᬩᤈ̶ݎ ੶ݸ҅ᕟӾಅํۖኮ੒᨝ݢզݶ෸ଚفےCAAnimationGroup੒᨝ Ӟᕟۖኮ੒᨝҅ਖ਼ਂכۖኮᕟ҅ฎCAAnimationጱৼᔄ҅ݢզ CAAnimationGroup——ۖኮᕟ ጱړᲫ଄ጱ෸ᳵฎଘىᗝkeyTimes҅ݱӻ ᮷੒ଫvaluesӾጱྯӞ଄̶ইຎဌํᦡ؀keyTimesӾጱྯӞӻ෸ᳵ 1.0҅ک᝜ࢱԅ0؀Ძ଄೰ਧ੒ଫጱ෸ᳵᅩٌ҅ݐىݢզԅ੒ଫጱ keyTimes ֵአොဩғ Ꮯ෸ᳵ̶ٵጱݎᦇ෸࢏ਫᴬᤩ᥶כ೮ݶྍ҅ᘒNSTimer෫ဩᏟ כෛ᷇ሲڬCADisplayLinkฎӞӻᦇ෸࢏҅ݢզֵᕲࢶդᎱӨᥤࢶጱ य़ᕅ60ེૢݦ̶ ᑁᰦಗᤈྯ҅ګጱ෸ᰦ๢ݎෛ᷇ሲ᥶ڬCADisplayLinkฎӞᐿզ੽଒ CADisplayLink ۖኮᕮ๳ݸ҅տᛔۖ᧣አᬯӻblock completion ਖ਼දݒᥤࢶં௔ጱդᎱනࣁᬯӻblockӾ animations ۖኮᔄࣳ option ۖኮ೮ᖅ෸ᳵ duration ᧔ก ݇හ finished))completion; (UIViewAnimationOptions)options completion:(void (^)(BOOL *)toView duration:(NSTimeInterval)duration options: + (void)transitionFromView:(UIView *)fromView toView:(UIView හਫሿ᫨࣋ۖኮ——݌ᥤࢶڍֵአUIViewۖኮ type ;link.paused = NO // ୏ত link.paused = YES; // ฮ؊ • ୏ত޾ฮ؊ forMode:NSDefaultRunLoopMode]; link addToRunLoop:[NSRunLoop mainRunLoop]] ڜԆ஗ሾᴚکے// Ⴒ selector:@selector(rotationChange)]; CADisplayLink *link = [CADisplayLink displayLinkWithTarget:self ਧԎ // ڜԆᬩᤈ஗ሾᴚکے• ਖ਼ดᐏ᱾ളႲ አොဩ᧣ݎਧ᥶ګਧԎCADisplayLinkଚ •
还剩11页未读

继续阅读

下载pdf到电脑,查找使用更方便

pdf的实际排版效果,会与网站的显示效果略有不同!!

需要 10 金币 [ 分享pdf获得金币 ] 0 人已下载

下载pdf

pdf贡献者

dante657

贡献于2018-03-28

下载需要 10 金币 [金币充值 ]
亲,您也可以通过 分享原创pdf 来获得金币奖励!
下载pdf