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