UIImageViewのようなものでうまく機能する次のものがあります。含まれているコントローラーで UIView アニメーションが機能するかどうかわかりません。ビューのフレームをアニメーション化していることはわかっていますが、これが機能するかどうかはわかりません (以下のコードは概念実証にすぎません)。しかし、それができたとしても、以下は機能しません。なぜそうしないのかについてのアイデアはありますか?
thx事前に
編集 #1
フレーズが含まれるカスタム ビュー コントローラーを黄色で表示するスクリーン ショットを追加しましholla
た。ご覧のとおり、以下のコードはフレームをアニメートしますが、そのビュー コントローラーの要素はアニメートしません。これは意図したものですか?回避策はありますか?
#import "MyViewController.h"
@interface ViewController ()
@property (nonatomic, strong) MyViewController *firstIV;
@end
- (void)viewDidLoad
{
[super viewDidLoad];
// lets add a few UIImageViews that we will animate
MyViewController *tmpFirstIV=[[MyViewController alloc] init];
tmpFirstIV.view.backgroundColor=[UIColor yellowColor];
tmpFirstIV.view.frame=CGRectMake(10.0f, 10.0f, 100.0f, 100.0f);
self.firstIV=tmpFirstIV;
[self addChildViewController:self.firstIV];
[self.view addSubview:self.firstIV.view];
[self.firstIV didMoveToParentViewController:self.firstIV];
-(void)updateAction:(id) sender{
NSLog(@"Here are some results");
if([self.updateButton.currentTitle isEqualToString:@"update this"]){
[UIView animateWithDuration:6.0f animations:^{ // yeah I know, long animation
self.firstIV.view.frame=CGRectMake(10.0f, 10.0f, 100.0f, 0.0f);
}];
[self.updateButton setTitle:@"make bigger" forState:UIControlStateNormal];
}else{
[UIView animateWithDuration:6.0f animations:^{ // equally long
self.firstIV.view.frame=CGRectMake(10.0f, 10.0f, 100.0f, 100.0f);
}];
[self.updateButton setTitle:@"update this" forState:UIControlStateNormal];
}
}
編集2
何もしていないようです... このレイヤーを調べます。
-(void)viewWillLayoutSubviews { [super viewWillLayoutSubviews];
CGRect viewBounds = self.view.bounds;
self.myLabel.frame = CGRectMake(100.0f,viewBounds.size.height-20.0f,50.0f,50.0f);
}