iOS App Development Study - How to print "Hello World!" in Storyboard and in Code
iOS 어플 개발 공부 - 두 가지 방법으로 "Hello World!" 출력하기(스토리보드, 코드)
- 개발 환경 : MacBook Pro (13-inch, M1, 2020), Monterey
- XCode : Version 13.1 (13A1030d)
- 시뮬레이터 : iPhone 11
import UIKit
class ViewController: UIViewController {
let textLabel = UILabel()
override func viewDidLoad() {
super.viewDidLoad()
self.view.addSubview(textLabel)
// UILabel에 들어갈 String
textLabel.text = "Hello World!"
// UILabel 배경 색
textLabel.backgroundColor = .red
// UILabel 텍스트 색
textLabel.textColor = .white
// UILabel 프레임 값 설정
textLabel.frame = CGRect(x: 100, y: 200, width: 150, height: 30)
// (100, 200)인 (x, y) 좌표에서 가로 150 높이 30인 프레임 셋팅
}
}
'iOS 앱 프로그래밍' 카테고리의 다른 글
[iOS Dev] Add UIButton, Alert programmatically (0) | 2021.11.18 |
---|---|
[iOS Dev][AutoLayout] How to add UILabel with constraints - programmatically (0) | 2021.11.17 |
[iOS Dev][Xcode] Assistant 기능 활용하기 (0) | 2021.11.12 |
[iOS Dev][Xcode] Xcode IDE 구성요소 (0) | 2021.11.11 |
[iOS Dev][Xcode] How to start My First Swift Project in Xcode (0) | 2021.11.11 |