我想用CAKeyframeAnimation旋转UIImageView。问题是阴影随着物体旋转,产生非真实效果...... The shadow must remain under the image, not rotating around it
这是我的代码。很简单:
=
SUMX (
VALUES ( YourTable[Item] ),
MAXX (
VALUES ( YourTable[Round] ),
CALCULATE( SUM ( YourTable[Value] ) )
)
)
任何解决方案?
答案 0 :(得分:0)
如果阴影随图像一起旋转。您可以通过在UIView
下方UIImageView
添加UIImageView
相同维度的UIView
来解决此问题。如果您为UIImageView
而不是let imagen:UIImageView = UIImageView(frame: CGRect(x: 100, y: 100, width: 100, height: 100))
imagen.center = CGPoint(x: 100, y: 100)
imagen.backgroundColor = UIColor.red
let belowView: UIView = UIView(frame: imagen.frame)
belowView.backgroundColor = UIColor.white
belowView.layer.shadowOpacity = 0.75
belowView.layer.shadowOffset = CGSize(width: 0, height: 15)
self.view.addSubview(belowView)
self.view.addSubview(imagen)
//Animación del ángulo
let animacionAngulo = CAKeyframeAnimation(keyPath: "transform.rotation.z")
var valoresAngulo = [NSNumber]()
let degrees:Float = 360
let radians = degrees * Float.pi / Float(180.0)
valoresAngulo.append(NSNumber(value: 0))
valoresAngulo.append(NSNumber(value: radians))
animacionAngulo.values = valoresAngulo
//Permite añadir varias animaciones y gestionarlas a la vez
animacionAngulo.repeatCount = Float.infinity
animacionAngulo.duration = 2.0
imagen.layer.add(animacionAngulo, forKey: nil)
添加阴影,则可以在这种情况下获得所需的效果。
awk