-4
"buttonPressed"버튼이 있습니다. 버튼을 누르면 x와 y 좌표를 해당 버튼으로 찾아야합니다. 나를 도울 수있는 아이디어가 있습니까? 당신은 행동의 보낸 사람 떨어져 X & Y를 원하는 것 같은UIButton의 x 및 y 좌표 얻기
UIButton *circleButton = [UIButton buttonWithType:UIButtonTypeRoundedRect];
circleButton.frame = rect;
circleButton.layer.cornerRadius = 8.0f;
[circleButton addTarget:self
action:@selector(buttonPressed:)
forControlEvents:UIControlEventTouchUpInside];
[self addSubview:circleButton];
-(void)buttonPressed:(id)sender
{
}
대답
- (IBAction)buttonPressed:(UIButton *)sender
{
CGPoint coordinates = sender.frame.origin;
CGFloat x = coordinates.x;
CGFloat y = coordinates.y;
}
? 어디로 보내시겠습니까? – wattson12
@ wattson12 괜찮습니다. 해결했습니다 –