我正在尝试列出Item可能包含的可能类型.但是我陷入困境,我无法调用Item.GetType()来遍历其属性,因为这只会返回它已经包含的类型的属性.
我尝试过TypeDescriptor.GetProperties(...)但是Attributes容器只包含一个XmlElementAttribute实例,它是应用于属性的最后一个实例(在本例中为WindowTemplate)
这一定是微不足道的,但我找不到任何解决我在线问题的方法.
[System.Xml.Serialization.XmlElementAttribute("ChildTemplate", typeof(ChildTmpl), Order = 1)]
[System.Xml.Serialization.XmlElementAttribute("WindowTmeplate", typeof(WindowTmpl), Order = 1)]
public object Item
{
get
{
return this.itemField;
}
set
{
this.itemField = value;
}
}
Run Code Online (Sandbox Code Playgroud) 在我的iPhone应用程序中,我有一个UIButton,当我按下另一个UIButton时,我旋转180度进入视图,然后再次点击时按钮再旋转180度回到它开始的位置.
这一切都在第一次完成360度全过程时工作正常,但是如果我尝试从头开始再次开始它会弹开180度然后尝试从那一点旋转它.谁能指出我正确的方向?这是我到目前为止的代码......
showAnimation= [CAKeyframeAnimation animationWithKeyPath:@"transform.rotation"];
showAnimation.duration = self.showAnimationDuration;
showAnimation.repeatCount = 1;
showAnimation.fillMode = kCAFillModeForwards;
showAnimation.removedOnCompletion = NO;
showAnimation.cumulative = YES;
showAnimation.delegate = self;
float currentAngle =[[[rotateMe.layer presentationLayer] valueForKeyPath:@"transform.rotation.z"] floatValue];
//Rotate 180 degrees from current rotation
showAnimation.values = [NSArray arrayWithObjects:
[NSNumber numberWithFloat:currentAngle],
[NSNumber numberWithFloat:currentAngle + (0.5 * M_PI)],
[NSNumber numberWithFloat:currentAngle + M_PI], nil];
[rotateMe.layer addAnimation:showAnimation forKey:@"show"];
Run Code Online (Sandbox Code Playgroud)
完成动画后,我将rotateMe.transform旋转更新为图层的旋转,以使其可用.
- (void)animationDidStop:(CAKeyframeAnimation *)anim finished:(BOOL)flag
{
float currentAngle =[[[self.layer presentationLayer] valueForKeyPath:@"transform.rotation.z"] floatValue];
NSLog(@"End: %f", currentAngle);
rotateMe.transform = CGAffineTransformMakeRotation(0);
}
Run Code Online (Sandbox Code Playgroud)
我已经取得了充分的工作效果
[UIView animateWithDuration:1.0f]
animations:^{
CGAffineTransform transform …Run Code Online (Sandbox Code Playgroud)