1

下面是我编写的一种响应震动的方法,以便按钮随机定位。

- (void)motionEnded:(UIEventSubtype)motion withEvent:(UIEvent *)event {

    if (motion == UIEventSubtypeMotionShake)

    {
        for(int i=0;i<8;i++){
          CGAffineTransform angle = CGAffineTransformMakeRotation(arc4random());
          shieldButton[i].transform = angle;

          shieldButton[i].frame = CGRectMake(arc4random()%900, arc4random()%400, 140, 171);
        }
    }

}

但是当我使用 arc4random 方法时,按钮的大小会减小。可能是什么原因 ...?

谢谢。

4

1 回答 1

1

这是来自Apple的文档

警告:如果变换属性不是恒等变换,则此属性的值未定义,因此应被忽略。

尝试设置界限。

于 2013-02-04T06:24:37.633 回答