Skip to content

chubura/create-omikuji-app

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

OmikujiApp - おみくじ

Progress

Main.storyboard

Utility Area

Library Pane

① Label
② Button

Inspector Pane
  • Style

    Font : 64
    Alignment : center
    Background : red
    Color : white

  • Constraints 制約

    Horizontally
    Vertically
    Width : 200
    Height : 200

    Horizontally margin-top : 20

add code

    @IBOutlet weak var myLabel: UILabel!  // ①Label
    @IBAction func getOmikuji(_ sender: Any) {   // ②Button
        // おみくじの配列
        let results = ["大吉", "", "中吉", "末吉", "", "大凶"]
        // 0 ~ n の乱数生成 ⇒ arc4random_uniform(n + 1) ※引数は UInt32 型
        let random = arc4random_uniform(UInt32(results.count))
        // resultsのrandom番目を myLabel に代入
        self.myLabel.text = results[Int(random)]
    }
    
    // View が表示されたあとの処理
    override func viewDidLoad() {
        super.viewDidLoad()
        // Do any additional setup after loading the view, typically from a nib.
        
        // 枠線を myLabel に適用
        myLabel.layer.borderColor = UIColor.black.cgColor // 枠線の色を指定
        myLabel.layer.borderWidth = 5 // 枠線の幅を指定
        myLabel.layer.cornerRadius = 50 // 枠線の角の丸みを指定
        myLabel.layer.masksToBounds = true // 枠線の外部分の切り取り
        myLabel.layer.cornerRadius = myLabel.bounds.width / 2 // 正円の指定
    }

Memo

Shortcut Key

  • Command + = : テキストと部品を同サイズにする
  • Command + Option + 0 : Utility Areaの表示非表示切り替え
  • Command + R : シュミレータの起動

About

成果物📱おみくじアプリ

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages