扫码关注官方订阅号
闭关修行中......
多看文档
UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom]; [button setFrame:CGRectMake(0, 0, 200, 80)]; [button setTitle:@"button" forState:UIControlStateNormal]; [button addTarget:self action:@selector(buttonAction:forEvent:) forControlEvents:UIControlEventAllTouchEvents]; [self.view addSubview:button]; - (void)buttonAction:(id)sender forEvent:(UIEvent *)event{ UITouchPhase phase = event.allTouches.anyObject.phase; if (phase == UITouchPhaseBegan) { NSLog(@"press"); } else if(phase == UITouchPhaseEnded){ NSLog(@"release"); } }
微信扫码关注PHP中文网服务号
QQ扫码加入技术交流群
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
PHP学习
技术支持
返回顶部
闭关修行中......