隐藏特定UIView的标签?

时间:2016-06-02 10:05:38

标签: ios objective-c

我在另一个view上制作了view并从右到左制作了一张可移动的label表单,问题是label在整个view上移动了我想仅在第二个view上显示它而不是在主视图上..如何隐藏label来自特定view? 这是我的代码

- (void)viewDidLoad {
    [super viewDidLoad];
    self.movelabel = [[UILabel alloc]initWithFrame:CGRectMake(200, 0, 200, 30)];    
    self.movelabel.text = @"This is my music line";
    [self.moveview addSubview:self.move];

    [NSTimer scheduledTimerWithTimeInterval:2.0                                    target:self selector:@selector(LabelAnimation) userInfo:nil repeats:YES];
}

-(void)LabelAnimation
{
    [UIView animateWithDuration:3.0f delay:0.0f options:UIViewAnimationOptionTransitionNone animations:^{
        self.move.frame = CGRectMake(-200, 0, 200, 60);
    } completion:^(BOOL finished)
     {
         self.move.frame = CGRectMake(200, 0, 200, 60);
     }];

}

三江源。

2 个答案:

答案 0 :(得分:3)

如果 self.move 是标签,则将其超级视图的 clipsToBounds 属性设置为

self.move.superview.clipsToBounds = YES;

如果self.move超出其超级视图范围,它将剪辑。

希望有所帮助:)

答案 1 :(得分:0)

隐藏UILabel 使用: -

yourLbl.hidden = YES;
[yourLbl setHidden:YES];

或删除

[yourLbl removeFromSuperview];
希望它可以帮助你。