zoukankan      html  css  js  c++  java
  • 文档学习

    #import "ViewController.h"

    @implementation ViewController

    - (void)viewDidLoad {

        [super viewDidLoad];

        // 1.

        UILabel *label = [[UILabel alloc] init];

        

        // 1.1 text

        label.text = @"//  ViewController.m01-UILabelCreated byjiaguanglei on 15/9/30Copyright (c) 2015年 roseonly. All rights reserved.";

        

        // 1.2 font

        /**

         const CGFloat UIFontWeightUltraLight;

         const CGFloat UIFontWeightThin;

         const CGFloat UIFontWeightLight;

         const CGFloat UIFontWeightRegular;

         const CGFloat UIFontWeightMedium;

         const CGFloat UIFontWeightSemibold;

         const CGFloat UIFontWeightBold;

         const CGFloat UIFontWeightHeavy;

         const CGFloat UIFontWeightBlack;

         

         + (UIFont *)systemFontOfSize:(CGFloat)fontSize;

         + (UIFont *)boldSystemFontOfSize:(CGFloat)fontSize;   -- 粗体

         + (UIFont *)italicSystemFontOfSize:(CGFloat)fontSize; -- 斜体

         + (UIFont *)systemFontOfSize:(CGFloat)fontSize weight:(CGFloat)weight NS_AVAILABLE_IOS(8_2);

         */

        label.font = [UIFont systemFontOfSize:20 weight:UIFontWeightBlack];

        

        // 1.3 textColor

        label.textColor = [UIColor magentaColor];

        

        // 1.4 shadowColor

        label.shadowColor = [UIColor greenColor];

        

        // 1.5 shadowOffset

        label.shadowOffset = CGSizeMake(2, 2);

        

        // 1.6 textAlignment

        /**

         NSTextAlignmentLeft      = 0,    // Visually left aligned

         NSTextAlignmentCenter    = 1,    // Visually centered

         NSTextAlignmentRight     = 2,    // Visually right aligned

         NSTextAlignmentJustified = 3,   // Fully-justified. The last line in a paragraph is natural-aligned.

         NSTextAlignmentNatural   = 4,  // Indicates the default alignment for script

         */

        label.textAlignment = NSTextAlignmentLeft;

        

        // 1.7 lineBreakMode

        /**  --- 设置换行格式

         *  with long lines

         NSLineBreakByWordWrapping = 0, --- 以单词为单位, 自动换行, 显示不全, 没有省略号

         NSLineBreakByCharWrapping --- 以字符为单位自动换行, 没有省略号

         NSLineBreakByClipping     --- 直接切除, 可能显示半个字符

         NSLineBreakByTruncatingHead --- 在行头部, 显示省略号

         NSLineBreakByTruncatingTail --- 在行尾部, 显示省略号

         NSLineBreakByTruncatingMiddle --- 在行中间, 显示省略号

         */

        label.lineBreakMode = NSLineBreakByTruncatingTail;

        // 1.8 highlighted

        // 1.8.1 highlightedTextColor

        label.highlighted = NO;

        label.highlightedTextColor = [UIColor blackColor];

        

        // 1.9 enabled

        // 1.9.1 userInteractionEnabled

        label.enabled = YES;

        label.userInteractionEnabled = YES;

        

        // 1.10 numberOfLines

        label.numberOfLines = 0;

        

        // 1.11 adjustsFontSizeToFitWidth

        label.adjustsFontSizeToFitWidth = YES;

        // 1.11.1 adjustsLetterSpacingToFitWidth  --  已过期, 用NSKernAttributeName替换

        // 1.11.2 minimumFontSize  --- --  已过期, 用minimumScaleFactor替代

        label.minimumScaleFactor = .8;

        // 1.11.3 baselineAdjustment

        /**

         UIBaselineAdjustmentAlignBaselines = 0, // default.

         UIBaselineAdjustmentAlignCenters,

         UIBaselineAdjustmentNone,

         */

        label.baselineAdjustment = UIBaselineAdjustmentNone;

        

        // 1.12 -- 绘图中可能会用到

        /**

         - (CGRect)textRectForBounds:(CGRect)bounds limitedToNumberOfLines:(NSInteger)numberOfLines;

         - (void)drawTextInRect:(CGRect)rect;

         

         @property(nonatomic) CGFloat preferredMaxLayoutWidth NS_AVAILABLE_IOS(6_0);

         */

        

        // 1.13 attributedText

        NSDictionary *attrs = @{NSForegroundColorAttributeName : [UIColor redColor]};

        NSAttributedString *attrString = [[NSAttributedString alloc] initWithString:label.text attributes:attrs];

        

        label.attributedText = attrString;

        

        CGSize size = [UIScreen mainScreen].bounds.size;

        label.frame = CGRectMake(10, 100, size.width - 20, 50);

        label.backgroundColor = [UIColor lightGrayColor];

        [self.view addSubview:label];

        

        

    }

  • 相关阅读:
    探偵ガリレオー転写る 完了
    探偵ガリレオー転写る3
    探偵ガリレオー転写る2
    探偵ガリレオー転写る1
    探偵ガリレオ 燃えるまで
    探偵ガリレオ2
    探偵ガリレオ1
    【转】2014找工作----扎实的基础和开阔的视野是企业最看重的因素
    三种交换两个整数的方法
    计算十进制整数的二进制中的1的数目
  • 原文地址:https://www.cnblogs.com/guangleijia/p/4848756.html
Copyright © 2011-2022 走看看