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.