728x90
반응형
[Review] (1주차) 실습
2022.06.19 - [Swift] - [Xcode] iOS Swift 앱 개발 Byte Degree - week.01
iOS 아키텍처 패턴 중 애플에서는 기본적으로 MVC 패턴을 가이드함
Product Name: HelloiOS
Organization Identifier: com.sehee
Interface: Storyboard (other options: SwiftUI)
Language: Swift (other options: Objective-C)
command + shift + C
글자 복사
기존 프레임 기반 레이아웃 → 오토레이아웃: 동적으로 뷰 위치
//
// SymbolRollerViewController.swift
// SymbolRoller
//
// Created by sehee on 2022/06/26.
//
import UIKit
class SymbolRollerViewController: UIViewController {
let symbols: [String] = ["sun.min", "moon", "cloud", "wind", "snowflake"]
@IBOutlet weak var imageView: UIImageView!
@IBOutlet weak var label: UILabel!
@IBOutlet weak var button: UIButton!
override func viewDidLoad() {
super.viewDidLoad()
// button.tintColor = UIColor.systemPink
// TO-DO:
// - 심볼에서, 하나를 임의로 추출해서
// 이미지와 텍스트를 설정
// DRY: Do not repeat yourself
reload()
// Do any additional setup after loading the view.
}
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
}
override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)
}
func reload() {
let symbol = symbols.randomElement()!
imageView.image = UIImage(systemName: symbol)
label.text = symbol
}
@IBAction func buttonTapped(_ sender: Any) {
reload()
}
/*
// MARK: - Navigation
// In a storyboard-based application, you will often want to do a little preparation before navigation
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
// Get the new view controller using segue.destination.
// Pass the selected object to the new view controller.
}
*/
}
ViewController: 페이지를 나타내기 위한 객체
option + shift + 8
° 기호
option + command + =
설정값 변경 전(주황색 표시) 업데이트
//
// WeatherViewController.swift
// SimpleWeather
//
// Created by sehee on 2022/06/26.
//
import UIKit
class WeatherViewController: UIViewController {
@IBOutlet weak var cityLabel: UILabel!
@IBOutlet weak var weatherImageView: UIImageView!
@IBOutlet weak var temperatureLabel: UILabel!
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
}
let cities = ["Seoul", "Tokyo", "LA", "Seattle"]
let weathers = ["cloud.fill", "sun.max.fill", "wind", "cloud.sun.rain.fill"]
@IBAction func changeeButtonTapped(_ sender: Any) {
print("도시, 온도, 날씨 이미지 변경하자!")
cityLabel.text = cities.randomElement()
let imageName = weathers.randomElement()!
weatherImageView.image = UIImage(systemName: imageName)?.withRenderingMode(.alwaysOriginal)
// alwaysTemplate의 경우 default Tint color 적용
let randomTemp = Int.random(in: 10..<30)
temperatureLabel.text = "\(randomTemp)°"
}
/*
// MARK: - Navigation
// In a storyboard-based application, you will often want to do a little preparation before navigation
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
// Get the new view controller using segue.destination.
// Pass the selected object to the new view controller.
}
*/
}
[Next] (3주차) 실습
2022.07.01 - [Swift] - [Xcode] iOS Swift 앱 개발 Byte Degree - week.03
728x90
728x90
'Development > Swift' 카테고리의 다른 글
[Swift] iOS 앱 개발(Xcode) Byte Degree - week.06 (0) | 2022.07.22 |
---|---|
[Swift] iOS 앱 개발(Xcode) Byte Degree - week.05 (0) | 2022.07.16 |
[Swift] iOS 앱 개발(Xcode) Byte Degree - week.04 (0) | 2022.07.10 |
[Swift] iOS 앱 개발(Xcode) Byte Degree - week.03 (0) | 2022.07.01 |
[Swift] iOS 앱 개발(Xcode) Byte Degree - week.01 (0) | 2022.06.19 |