zoukankan      html  css  js  c++  java
  • IOS#UI部分UILabel

    本来已经写了很多,就因为切换页面就没有了,以后切之前得注意了 mac电脑的伤不起

    UI里面有很多控件比如UIView UIControl UILabel UIButton UIScrollView  UIWindow   UIWebView    UITabBar UITableView UITableViewCell UIToolbar UITextField UITextView   UIImageView UIPageControl UIPickerView UIProgressView UIAlertView  UISearchBar UISegmentedControl UISearchBar UISlider UISwitch UICollectionView 6.0 UICollectionReusableView等

    控制器有

    UIPageViewController UIPopoverController UIImagePickerController UINavigationController UISplitViewController UICollectionViewController UITableViewController

    开在写了,废话少说,

    先将UILabel UIView和UIResponder后面在写,

    UILabel的

    - (void)viewDidLoad
    {
        [super viewDidLoad];
        self.view.backgroundColor = [UIColor whiteColor];
        UILabel *aLabel = [[UILabel alloc] initWithFrame:CGRectMake(20, 100, 280, 100)];
        aLabel.backgroundColor = [UIColor greenColor];
        aLabel.text = @"这是我在2013年的程序,今天也是我要写ios、mac和操作系统相关的技术博文,我的bolg分别是(1)http://www.cnblogs.com/leevaboo(2)http://blog.csdn.net/leevaboo,(3)http://3660064.blog.51cto.com";
        aLabel.textAlignment = NSTextAlignmentCenter;//左中右对其的模式 default is left
        aLabel.textColor = [UIColor blueColor];//文本颜色default is blackColor
        aLabel.font = [UIFont systemFontOfSize:20];//字体的大小default is 17
        aLabel.shadowColor = [UIColor redColor];//阴影default is nil
        aLabel.shadowOffset = CGSizeMake(0, 1);//阴影的位置,按照xy轴的坐标位置来,default is (0 -1)表示x = 0 ,y = -1 表示在阴影在正下方 x轴左到右是负到正,y上到下是负到正
        aLabel.lineBreakMode = NSLineBreakByTruncatingTail;//文本超过label的边界的文本截取方式default is NSLineBreakByTruncatingTail
        aLabel.highlightedTextColor = [UIColor purpleColor];//设置文本的高亮颜色 default is nil
        aLabel.highlighted = NO;//打开高亮default is NO
        aLabel.userInteractionEnabled = NO;//是否交互.default is NP
        aLabel.adjustsFontSizeToFitWidth = NO;//根据宽调整字体的大小 但是numberOfLines = 1;default is NO
        aLabel.numberOfLines = 0;
        float height = [aLabel.text sizeWithFont:aLabel.font constrainedToSize:CGSizeMake(280, 100000) lineBreakMode:NSLineBreakByWordWrapping].height;//根据字符串的长度和字号的大小和Label的宽度自动计算label的高度
        aLabel.baselineAdjustment = UIBaselineAdjustmentAlignBaselines;//设置label的基准线
        aLabel.frame = CGRectMake(20, 100, 280, height);
        [self.view addSubview:aLabel];
        [aLabel release];
        // Do any additional setup after loading the view.
    }

  • 相关阅读:
    自动化骨架屏生成思路
    npm查看包版本
    icon最佳实践
    node多进程模块
    node环境清空控制台的代码
    commonjs规范
    package.json中的devDependencies和dependencies有啥区别?
    delphi ExecWB
    delphi execCommand
    delphi 带历史信息的菜单
  • 原文地址:https://www.cnblogs.com/leevaboo/p/2841859.html
Copyright © 2011-2022 走看看