Skip to content

Instantly share code, notes, and snippets.

@chuck0523
Created June 14, 2016 03:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chuck0523/2e0fe2ea5be2383bf63b8d4698eee62b to your computer and use it in GitHub Desktop.
Save chuck0523/2e0fe2ea5be2383bf63b8d4698eee62b to your computer and use it in GitHub Desktop.
//
// ViewController.swift
// 001-uilabelde
//
// Created by chuck on 6/14/16.
// Copyright © 2016 chuck. All rights reserved.
//
import UIKit
class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
// Labelを作成.
let myLabel: UILabel = UILabel(frame: CGRectMake(0,0,200,50))
// 背景をオレンジ色にする.
myLabel.backgroundColor = UIColor.orangeColor()
// Labelに文字を代入.
myLabel.text = "Hello, Swift!"
myLabel.textColor = UIColor.whiteColor()
myLabel.shadowColor = UIColor.grayColor()
myLabel.textAlignment = NSTextAlignment.Center
// 配置する座標を設定する.
myLabel.layer.position = CGPoint(x: self.view.bounds.width/2, y: 200)
// Viewの背景色を青にする.
// self.view.backgroundColor = UIColor.cyanColor()
self.view.backgroundColor = UIColor.cyanColor()
// ViewにLabelを追加.
self.view.addSubview(myLabel)
// Do any additional setup after loading the view, typically from a nib.
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment