所以首先我将UIButton子类化。值得一提的是,如果我将旋转应用于其起作用的UIButton。但是,当我将其应用于UIImageView时,根本没有旋转。因此,处理动画的代码如下。
private float RotationAngle { get; set; } = (float)Math.PI / 2;
private void SpinWithOptions(UIViewAnimationOptions animationOptions)
{
Animate(0.5,animationOptions,() => {
// Animation
ImageView.Transform = CGAffineTransform.Rotate(ImageView.Transform,RotationAngle);
},() => {
// Completion
if (Animating)
{
SpinWithOptions(UIViewAnimationOptions.CurveLinear);
}
else if (animationOptions != UIViewAnimationOptions.CurveEaseOut)
{
SpinWithOptions(UIViewAnimationOptions.CurveEaseOut);
}
});
}
我唯一要做的就是像这样设置拐角半径。
Layer.CornerRadius = Bounds.Size.Width / 2;
我无法理解为什么将其应用于UIButtons Transfrom但不适用于UIImageView时为何起作用