首页 > 其他 > 详细

如何处理UIVIew addsubview 不显示subview

时间:2016-01-10 00:25:24      阅读:200      评论:0      收藏:0      [点我收藏+]
老代码: addsubview不显示uilabel
-(UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section
{
    UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0,0,tableView.frame.size.width,50)];
    UILabel *label=[[UILabel new]initWithFrame:CGRectMake(0, 0 ,200, 50)];

    label.text=@"加载更多...";
    label.textColor=[UserSetting getIntance].titleColor;
    label.backgroundColor=[UserSetting getIntance].titleColor;
    [view addSubview:label];
     [view setBackgroundColor:[UserSetting getIntance].mainColor];
    return view;
}
原因在于:addsubview 没有使 UILabel的大小生效
需要在addsuview后面再赋值frame.
新代码如下
-(UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section
{
    UIView *view = [[UIView alloc]     initWithFrame:CGRectMake(0,0,tableView.frame.size.width,50)];
    UILabel *label=[[UILabel new]init];

    label.text=@"加载更多...";
    label.textColor=[UserSetting getIntance].titleColor;
    label.backgroundColor=[UserSetting getIntance].titleColor;
    [view addSubview:label];
    label.frame=CGRectMake(0, 0 ,200, 50);
    [view setBackgroundColor:[UserSetting getIntance].mainColor];
    return view;
}

  

如何处理UIVIew addsubview 不显示subview

原文:http://www.cnblogs.com/Zoes/p/5117587.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!