两个UILabel彼此隐藏,隐藏顶部的UILabel

时间:2012-01-25 14:20:01

标签: objective-c ios xcode

如标题中所述,我有一个应用程序,其中两个UILabel彼此相同。如果我想以编程方式隐藏到最顶层,可以使用myLabel.hidden = true。

如果我在Android中使用myLabel.setVisibility(View.Gone);),则此标签下的标签将向上移动。

但如果我在iOS上这样做,标签就会被隐藏,但仍有空格而不是标签。

enter image description here

知道如何解决这个问题吗?

2 个答案:

答案 0 :(得分:2)

隐藏第二个时,获取其框架,隐藏它并更改第三个框架属性:

CGRect secondFrame = secondLabel.frame;
secondLabel.hidden = YES;
thirdLabel.frame = secondFrame;

答案 1 :(得分:0)

做这样的事情:

[UIView animateWithDuration:0.3
                 animations:^{label1.alpha = 0;
                              label2.frame = label1.frame}
                 completion:NULL];