0

我有一个 UIView,当方向改变时我手动旋转,这个 UIView 承载了许多按钮,我也想根据方向的改变来旋转它们。

我正在这样做:

  CGAffineTransform rotation = CGAffineTransformMakeRotation(M_PI / -4);

    [UIView animateWithDuration:0.25 animations:^
    {

        self.parentView.firstButton.transform =   CGAffineTransformConcat(self.parentView.firstButton.transform, rotation);
        self.parentView.secondButton.transform = CGAffineTransformConcat(self.parentView.secondButton.transform, rotation);
        self.parentView.thirdButton.transform = CGAffineTransformConcat(self.parentView.thirdButton.transform, rotation);
        self.parentView.transform = CGAffineTransformConcat(self.parentView.transform, rotation);
    }
        completion:^(BOOL finished)
    {
    }];

parentView 确实可以正确旋转,但其他按钮没有!我需要在另一个电话中执行轮换吗?因为我不能在同一个块中旋转按钮及其父视图?

谢谢

4

1 回答 1

0

旋转父视图应该足够了。确保您self.parentView.transform先分配。尝试直接分配适当的变换,CGAffineTransformMakeRotation()而不依赖于变换属性的当前状态(如使用CGAffineTransformConcat())。不要忘记确保子视图确实是 parentView 的子视图 - a[self.parentView addSubview:...]应该出现在某个地方。如果您使用 IB 设置子视图,这可能会很棘手;检查IB的视图层次树!

于 2013-02-10T10:32:58.673 回答