我使用容器视图作为两个子视图的超级视图。我想将一个子视图“翻转”到另一个子视图。第一个子视图恰好是空白的,第二个子视图是UILabel
有一些文本的。
翻转正在发生,但我没有看到我的子视图。
我想过渡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];
}