UILabel设置位置 不管是什么控件 添加到某个位置或者某控件上 都要设置它的frame值 否则是看不到的

来源:互联网 发布:linux函数 sleep 编辑:程序博客网 时间:2024/04/27 18:52

UIImage *ballImage = [UIImageimageNamed:@"ball_red"];

        UIImageView * ballImgView = [[UIImageViewalloc ]initWithFrame:CGRectMake(60+(i*35),350,30,30)];

        [ballImgViewsetImage:ballImage];

        showLabel = [[UILabelalloc]init ];//WithFrame:CGRectMake(60+(i*35), 350, 30, 30)];

        NSNumber *SSQRedBall= [randRedArrayobjectAtIndex:i];

        showLabel.frame = ballImgView.bounds;

        showLabel.textAlignment =NSTextAlignmentCenter;

        showLabel.text = [NSStringstringWithFormat:@"%d",SSQRedBall.intValue-BALL_TAG+1];

        [ballImgViewaddSubview:showLabel];

        [_backgroundViewaddSubview:ballImgView];

一定记住 不管是哪个控件添加到哪个控件上 都要添加frame的值 否则是 看不到的 这是我们经常犯错的地方可以参考这个例子
0 0