0
프로그래밍 방식으로 xCode에 사용자 지정 botton (이미지)을 삽입합니다. UIbutton을 클릭 한 후 버튼을 iPhone 화면의 맞춤 위치로 이동하려고합니다.단추를 클릭 한 후 이미지 이동
프로그래밍 방식 버튼 : 내가 클릭 한 후 버튼을 이동하기 위해 노력하고있어
self.view = [[UIView alloc] initWithFrame:[[UIScreen mainScreen] applicationFrame]];
UIButton *MyButton = [UIButton buttonWithType:nil];
MyButton.frame = CGRectMake(100, 170, 100, 30);
[MyButton setImage:[UIImage imageNamed:@"tap.png"] forState:nil];
[self.view addSubview:MyButton];
[MyButton addTarget:self action:@selector(buttonPressed) forControlEvents:UIControlEventTouchUpInside];
.
-(void)buttonPressed {
NSLog(@"Button Pressed!");
CGRect frame = MyButton.frame;
frame.origin.x = 100; // new x coordinate
frame.origin.y = 4; // new y coordinate
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration: 0.1];
MyButton.frame = frame;
[UIView commitAnimations];
}
하지만 아무 것도 발생하지 않습니다.
i를 .h
파일
IBOutlet UIButton *MyButton;
@property (nonatomic, retain) UIButton *MyButton;
으악 죄송 이미지가 costum있는 UIButton – Frenck
당신이 가지고있는 정확한 문제에 대한 추정 할 수있다? 당신이 아주 가까이있는 것처럼 보입니다. – FreeAsInBeer
메시지를 편집했습니다. @FreeAsInBeer 저를 도울 수 있기를 바랍니다. – Frenck