基本触摸事件
#pragma mark - 重写方法
#pragma mark 触摸开始
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
NSLog(@"touchesBegan");
NSLog(@"%s",__FUNCTION__);
}
#pragma mark - 触摸移动
- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event
{
NSLog(@"touchesMoved");
NSLog(@"%s",__FUNCTION__);
}
#pragma mark - 触摸结束
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event
{
NSLog(@"touchesEnded");
NSLog(@"%s",__FUNCTION__);
CGFloat red = arc4random() % 256 / 255.0;
CGFloat blue = arc4random() % 256 / 255.0;
CGFloat green = arc4random() % 256 / 255.0;
self.backgroundColor = [UIColor colorWithRed:red green:green blue:blue alpha:1.0];
}
#pragma mark - 触摸取消
- (void)touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event
{
NSLog(@"touchesCancelled");
NSLog(@"%s",__FUNCTION__);
}
版权声明:本文为博主原创文章,未经博主允许不得转载。
时间: 2024-10-03 00:39:36