我正在尝试旋转图像(三角形)以使其与重力对齐。所以那个角落总是向下的。但没有任何帮助。三角要疯了。
double accelX = motion.userAcceleration.x;
double accelY = motion.userAcceleration.y;
rollingX = (accelX * kFilteringFactor) + (rollingX * (1.0 - kFilteringFactor));
rollingY = (accelY * kFilteringFactor) + (rollingY * (1.0 - kFilteringFactor));
accelX = accelX - rollingX;
accelY = accelY - rollingY;
float angle = atan2(accelY, accelX);
[rootLayer setAnchorPoint:CGPointMake(0.5, 0.5)];
CATransform3D rotation = CATransform3DIdentity;
rotation.m34 = 1.0f / -500.0f;
rotation = CATransform3DRotate(rotation, angle, 0.0f, 0.0f, 1.0f);
rootLayer.sublayerTransform = rotation;