にこのコード
それを縮小するために逆を行いますファイル
#import <UIKit/UIKit.h>
@interface ExpandedViewController : UIViewController
{
UIView * expandiView;
BOOL viewExpanded;
}
- (IBAction)expandOrShrinkView:(id)sender;
@end
とあなたの.mファイルに
- (void)viewDidLoad
{
[super viewDidLoad];
aview = [[UIView alloc] initWithFrame:CGRectMake(10, 10, 100, 100)];
aview.backgroundColor = [UIColor redColor];
[self.view addSubview:aview];
viewExpanded = NO;
}
そして、あなたのボタンアクションで
は、このコードを追加
- (IBAction)expandOrShrinkView:(id)sender {
[UIView animateWithDuration:0.8f delay:0.0f options:UIViewAnimationOptionTransitionNone animations: ^{
if (!viewExpanded) {
viewExpanded = YES;
aview.frame = CGRectMake(10, 10, 100, 200);
}else{
viewExpanded = NO;
aview.frame = CGRectMake(10, 10, 100, 100);
}
} completion:nil];
}
ボタン初めてそれが下からビューを展開し、あなたがボタン秒をクリックしたときにクリックし
時間は...
を下の変更あなたの必要性にフレームサイズからの眺めを縮小し、あなたは別のボタンに機能を縮小したい場合は、この
のような2つのアクションメソッドを使用するよりもします
- (IBAction)expandView:(id)sender {
[UIView animateWithDuration:0.8f delay:0.0f options:UIViewAnimationOptionTransitionNone animations: ^{
aview.frame = CGRectMake(10, 10, 100, 200);
} completion:nil];
}
- (IBAction)ShrinkView:(id)sender {
[UIView animateWithDuration:0.8f delay:0.0f options:UIViewAnimationOptionTransitionNone animations: ^{
aview.frame = CGRectMake(10, 10, 100, 100);
} completion:nil];
}
グレート私はそれを見ていきます。 –
確かに...問題がある場合は教えてください – iAmitWagh