[udemy] section 5

서희찬·2022년 5월 10일
0

swift

목록 보기
8/17
post-thumbnail

앞의 section4를 토대로 앱을 만들어보자.


질문을 하면 랜덤으로 답해주는 어플이다.

https://github.com/appbrewery/Magic-8-Ball-iOS13
클론을 받아서 여기서 진행해주자 !

우선, 만들기직전에 간단하게 생각해보자.

위와같이 구성될것같다..
그렇다면 지난 세션에서 만든 다이스 앱과는 크게 다르지않을것이다.

UI 작성


이런식으로 label, image, btn 을 추가해주자.

viewController 작성

우선, 연결해준다..!
UI가 약간 바뀐 이유는 클론한 앱에서 assitant를 지원하지 않았다.. 왜지... 찾아보니
https://stackoverflow.com/questions/27426340/storyboard-assistant-editor-stopped-showing-associated-file
이 문제인거같은데 난 DeriveData 폴더를 못찾아서 그냥 새로 팠다....

나머지 코드를 작성해주면..

//
//  ViewController.swift
//  Magic 8Ball
//
//  Created by 서희찬 on 2022/05/11.
//

import UIKit

class ViewController: UIViewController {

    @IBOutlet weak var aksImg: UIImageView!

    @IBAction func askBtn(_ sender: UIButton) {
        
        let askArr = [ #imageLiteral(resourceName: "ball4"), #imageLiteral(resourceName: "ball3"), #imageLiteral(resourceName: "ball2"), #imageLiteral(resourceName: "ball3"), #imageLiteral(resourceName: "ball3")]
        
        aksImg.image = askArr.randomElement()
        
    }
    
}

음...별거없다...

Tip From Angela - Nothing Easy is Worth Doing

a lot of things that require a lot of dedication to be able to achieve the resut that people get.

So, in order to get good at something, you've got to show up, you've got up put in the hours, and the you'll get the result that you deserver

So put in the work, put in the effort, and the results will happen, I promise, and I am here for you and .....

Just Kepp Going ...

profile
부족한 실력을 엉덩이 힘으로 채워나가는 개발자 서희찬입니다 :)

0개의 댓글