源代码地址:http://url.cn/Sj5SSX
效果图:
工程图:
注意,此代码中要加入第三方库PendulumView。
RootViewController.m
//点击任何处弹出提示 -(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event{ UIColor *ballColor = [UIColor colorWithRed:0.47 green:0.60 blue:0.89 alpha:1]; PendulumView *pendulum = [[PendulumView alloc] initWithFrame:self.view.bounds ballColor:ballColor]; [self.view addSubview:pendulum]; }