Graphics Programs Reference
In-Depth Information
Notice that
motionBegan:withEvent:
has a
UIEventSubtype
argument. This
argument holds the type of motion event that triggered this method. Right now, there is
only one type of motion event: a shake. In the future, there may be more. You should
maintain future compatibility by making sure that only shake events change the color of
the
HypnosisView
. In
HypnosisView.m
, add the following code to
mo-
tionBegan:withEvent:
.
- (void)motionBegan:(UIEventSubtype)motion withEvent:(UIEvent *)event
{
if (motion == UIEventSubtypeMotionShake) {
NSLog(@"Device started shaking!")
[self setCircleColor:[UIColor redColor]];
}
}