📱 UIKitとSwiftUIの違い
🧱 よく使われるUI部品(UIKit)
- UILabel:テキスト表示
- UIButton:ボタン
- UITextField:一行入力欄
- UIImageView:画像表示
- UITableView:リスト表示
- UICollectionView:グリッド表示
🧱 よく使われるUI部品(SwiftUI)
🎨 UI設計で意識すること
📚 Auto Layoutとは?
Auto Layout を使うと、画面サイズに応じてUIを柔軟に配置できます。Storyboardでもコードでも設定可能です。
💡 例:UIKitでボタンを設置
let button = UIButton(type: .system)
button.setTitle("タップ", for: .normal)
button.frame = CGRect(x: 100, y: 100, width: 100, height: 44)
button.addTarget(self, action: #selector(tapAction), for: .touchUpInside)
view.addSubview(button)