我使用容器视图作为两个子视图的超级视图。我想“翻转”一个子视图到另一个子视图。第一个子视图是空白的,第二个子视图是UILabel
,它有一些文本。UIView过渡动画不显示子视图
翻转正在发生,但我没有看到我的子视图。
我想将blankLabelView
转换为labelToTransition
。有任何想法吗?谢谢!
代码:
-(void)viewDidLoad {
CGRect labelFrame = CGRectMake(100.0, 217.0, 125.0, 34.0);
self.labelContainerView = [[UIView alloc] initWithFrame:labelFrame];
// If I change the background color to something other than clear
// I can see that this view is flipping, otherwise it appears that
// nothing happens.
self.labelContainerView.backgroundColor = [UIColor clearColor];
[self.someSuperview addSubview:self.labelContainerView];
UILabel *label = [[UILabel alloc] initWithFrame:labelFrame];
label.backgroundColor = [UIColor clearColor];
label.lineBreakMode = UILineBreakModeWordWrap;
label.numberOfLines = 2;
label.textAlignment = UITextAlignmentCenter;
self.labelToTransition = label;
UIView *blankView = [[UIView alloc] initWithFrame:labelFrame];
blankView.backgroundColor = [UIColor clearColor];
self.blankLabelView = blankView;
}
-(void)viewWillAppear {
self.labelToTransition.text = @"some text from a model object";
[self.labelContainerView addSubview:self.blankLabelView];
}
-(void)flipViewAnimation {
UIView *containerView = self.labelContainerView;
[UIView transitionWithView:containerView duration:1.0 options:UIViewAnimationOptionTransitionFlipFromBottom
animations:^{
[self.blankLabelView removeFromSuperview];
[containerView addSubview:self.labelToTransition];
}
completion:NULL];
}
这是一个帧的问题。两个标签的容器视图都有适当的框架设置。标签子视图没有。具体来说,我错误地设置了原点,以便它不出现在容器视图中。感谢您的建议! – 2012-01-11 17:10:07