하위 클래스에 이라는 부동 소수점이 있고 @dynamic
으로 표시된 속성이 있습니다. 서브 클래스에 대해 actionForKey
, initWithLayer
, needsDisplayForKey
및 drawInContext
메소드를 구현했습니다. 어떻게 든 CABasicAnimation
가 반환되는속성 변경에 애니메이션 적용되지 않는 CALayer 서브 클래스
myCASublayer.animAngle = 0.5f;
제대로 계층 "animAngle
"를 사용 할 수 없습니다 :
- (id<CAAction>)actionForKey:(NString *)event {
if([event isEqualToString:@"animAngle"]) {
return [self animationForKey:event];
}
return [super actionForKey:event];
}
그리고 Someother 클래스에서
- (CABasicAnimation *)animationForKey:(NSString *)key
{
NSString *animValue = [[self presentationLayer] valueForKey:key];// Logs as 0
CABasicAnimation *anim;
if([key isEqualToString:@"animAngle"]) {
anim = [CABasicAnimation animationWithKeyPath:@"transform.rotation.z"];
anim.repeatCount = HUGE_VAL;
anim.autoreverses = YES;
//anim.fromValue = [[self presentationLayer] valueForKey:key]; // setting animation value from layer property as in here does not work.
anim.fromValue = [NSNumber numberWithFloat:0.5f]; // This works
}
anim.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
anim.duration = 0.11;
return anim;
}
을 다음과 같이 actionForKey
에 대한 정의는 재산. 내가 여기서 잘못했을 가능성은 무엇입니까?
하나라고는'다른'wiggleAngle' –
@RobvanderVeer입니다 animAngle')
CALayers 그리 않습니다 싫어. 그것의 animAngle. – rawatm
@ basstrekerk87, 다음 번에 더 나은 복사/붙여 넣기를 수행하면 오류가 저장됩니다! 실제로 코드를 들여 쓰기 할 필요가 없다는 것을 알고 계십니까? 버튼을 사용하거나 3 개의 역 따옴표 (')로 시작하십시오. –