【发布时间】:2012-01-31 05:27:16
【问题描述】:
我使用容器视图作为两个子视图的超级视图。我想将一个子视图“翻转”到另一个子视图。第一个子视图恰好是空白的,而第二个子视图是 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];
}
【问题讨论】:
标签: iphone ios uiview uiviewanimationtransition