zoukankan      html  css  js  c++  java
  • iOS tip:让你的footTableView的UILabel居中

    如果你需要编写一个软件,同时支持portrait&landscape,你会遇到一个问题:当屏幕旋转后,如果才能确保一些可视化的things依然居中呢。下面是一个简单的例子,无论设备是否旋转,UITableView的footer中的UILabel保持居中的方法。

     1     //create the uiview container
     2     UIView *tfooterView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, _tableView.frame.size.width, 45)];
     3     tfooterView.autoresizingMask = UIViewAutoresizingFlexibleWidth;
     4     //create the uilabel for the text
     5     UILabel *label3 = [[UILabel alloc] initWithFrame:CGRectMake(_tableView.frame.size.width/2-120, 0, 240, 35)];
     6     label3.backgroundColor = [UIColor clearColor];
     7     label3.font = [UIFont systemFontOfSize:12];
     8     label3.numberOfLines = 2;
     9     label3.lineBreakMode = UILineBreakModeWordWrap;
    10     label3.textAlignment = UITextAlignmentCenter;
    11     label3.text = @"Some text you want centered in your tableFooterView.";
    12     label3.autoresizingMask = UIViewAutoresizingFlexibleRightMargin | UIViewAutoresizingFlexibleLeftMargin;
    13     //add the label to the view
    14     [tfooterView addSubview:label3];
    15     //add the view to the uitableview footer
    16     _tableView.tableFooterView = tfooterView;
    作者:W.M.steve
    出处:http://www.cnblogs.com/weisteve/
    本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利。
  • 相关阅读:
    HTTP下载文件校验失败原因分析与解决
    读《软件测试的艺术》
    CXF wsdl2java 错误
    oracle 存储过程 多参数 多返回值
    ORACLE 函数 调用
    typescript学习入门(学习笔记)
    js常用方法总结
    jenkins安装及项目构建发布回滚
    Centos8中创建LVM精简逻辑卷
    k8s kubectl命令自动补全
  • 原文地址:https://www.cnblogs.com/weisteve/p/3033168.html
Copyright © 2011-2022 走看看