//
// ViewController.swift
// UILabel
//
// Created by hong wang on 2017/6/1.
// Copyright © 2017年 appio. All rights reserved.
//
import UIKit
class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
//Demo for uiLabel swift3.1
let label:UILabel = UILabel(frame: CGRect(x: 10, y: 100, width: 200, height: 100) )
//显示文字
label.text = "Hello World"
//设置字体大小
label.font = UIFont.italicSystemFont(ofSize: 20)
//label.font = UIFont.boldSystemFont(ofSize: 20)
//设置字体颜色
label.textColor = UIColor.red
//设置背景颜色
label.backgroundColor = UIColor.green
//文字位置对齐方式3种
//label.textAlignment = NSTextAlignment.left
label.textAlignment = NSTextAlignment.center
//label.textAlignment = NSTextAlignment.right
//设置文字阴影 颜色和偏移
label.shadowColor = UIColor.white
label.shadowOffset = CGSize(width: 1, height: 1)
//设置自动显示行数 0自动选择
label.numberOfLines = 0
//将label添加进当前视图
self.view.addSubview(label)
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
}
// ViewController.swift
// UILabel
//
// Created by hong wang on 2017/6/1.
// Copyright © 2017年 appio. All rights reserved.
//
import UIKit
class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
//Demo for uiLabel swift3.1
let label:UILabel = UILabel(frame: CGRect(x: 10, y: 100, width: 200, height: 100) )
//显示文字
label.text = "Hello World"
//设置字体大小
label.font = UIFont.italicSystemFont(ofSize: 20)
//label.font = UIFont.boldSystemFont(ofSize: 20)
//设置字体颜色
label.textColor = UIColor.red
//设置背景颜色
label.backgroundColor = UIColor.green
//文字位置对齐方式3种
//label.textAlignment = NSTextAlignment.left
label.textAlignment = NSTextAlignment.center
//label.textAlignment = NSTextAlignment.right
//设置文字阴影 颜色和偏移
label.shadowColor = UIColor.white
label.shadowOffset = CGSize(width: 1, height: 1)
//设置自动显示行数 0自动选择
label.numberOfLines = 0
//将label添加进当前视图
self.view.addSubview(label)
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
}