문제

below is a method i've written to respond to a shake so that the buttons are positioned randomly.

- (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);
        }
    }

}

but when I use the arc4random method, the size of the button gets reduced. what could be the reason ...?

Thanks.

도움이 되었습니까?

해결책

This is from Apple's documentation

Warning: If the transform property is not the identity transform, the value of this property is undefined and therefore should be ignored.

Try setting bounds.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top