zoukankan      html  css  js  c++  java
  • Displaying Static Text with UILabel

    头文件:

     

    #import <UIKit/UIKit.h>

     

    @interface ViewController : UIViewController

     

    @property (nonatomic,strong) UILabel *myLabel;

     

    @end

     

    实现:

    #import "ViewController.h"

     

    @interfaceViewController ()

     

    @end

     

    @implementation ViewController

     

    - (void)viewDidLoad

    {

        [superviewDidLoad];

        CGRect lableFrame = CGRectMake(0.0f,0.0f,100.0f,500.0f);

        self.myLabel = [[UILabel alloc] initWithFrame:lableFrame];

        self.myLabel.text = @"show this text in iPhonesomething like that,I just want to make the text longer.";

        self.myLabel.font = [UIFontboldSystemFontOfSize:14.0f];

        self.myLabel.numberOfLines = 9//只增大labelFrame的高度不行,

                                        //要配合这个property使用。

        //self.myLabel.adjustsFontSizeToFitWidth = YES;//这个属性会根据labelFramed的高度重新设置子的大小,来适应其高度,但是只有在numberOfLines1的时候有作用。

        self.myLabel.shadowColor = [UIColorredColor];

        self.myLabel.shadowOffset = CGSizeMake(1.0f, 2.0f);//阴影为向右1point,向下2points.若设置为(-1.0f, -2.0f,则为向左向上。

        [self.myLabel sizeToFit];

        self.myLabel.textAlignment = NSTextAlignmentCenter;

        self.myLabel.center = self.view.center;

        [self.view addSubview:self.myLabel];

    }

     

    - (void)didReceiveMemoryWarning

    {

        [superdidReceiveMemoryWarning];

    }

     

    @end

  • 相关阅读:
    C#小数点位数处理方法
    C#获取硬盘空间信息
    Linux双网卡绑定实现负载均衡
    CentOS、Ubuntu配置网卡子接口
    CentOS7修改网卡名称,禁用ipv6
    centos命令自动补全增强
    使用批处理文件访问ORACLE数据库
    Mac 常用终端命令
    常用正则表达式
    pickle 模块
  • 原文地址:https://www.cnblogs.com/liuhong/p/3278496.html
Copyright © 2011-2022 走看看