【ios】---SwiftUI开发从入门到放弃

SwiftUI开发从入门到放弃

基本知识

与H5相对比

开发ios app

1.打开Xcode,新建项目


2.开发代码

swift 复制代码
import SwiftUI
func mySelect() -> String {
    return ["🍏", "🍎", "🍐", "🍊", "🍋", "🍋‍🟩", "🍌", "🍉",
    "🍇", "🍓", "🫐", "🍈", "🍒", "🍑", "🥭", "🍍", "🥥", "🥝"
    ].randomElement()!
}


struct ContentView: View {
    @State private var today = mySelect()
    var body: some View {
        VStack {
            Spacer()
            Text("\(today)") // html框架
                .font(.system(size: 100)) // css样式
                .padding()
            Spacer()
            Button("今天吃啥?"){
                // js脚本
                today = mySelect()
            }
            .padding()
            .background(.teal)
            .foregroundStyle(.white)
            .cornerRadius(30)
            Spacer()
        }
        .padding()
    }
}

#Preview {
    ContentView()
}

3.制作图标

画布大小1024 *1024

4.替换图标

5.修改名称

6.运行




macos,手表,电视,vision pro等同理

Xcode界面

如有不足,请多指教,

未完待续,持续更新!

大家一起进步!

相关推荐
HarderCoder1 天前
Swift 6 并发时代,如何优雅地“抢救”你的单例?
swift
zhangmeng1 天前
FlutterBoost在iOS26真机运行崩溃问题
flutter·app·swift
HarderCoder1 天前
SwiftUI 踩坑记:onAppear / task 不回调?90% 撞上了“空壳视图”!
swift
HarderCoder1 天前
@isolated(any) 深度解析:Swift 并发中的“隔离追踪器”
swift
大熊猫侯佩1 天前
桃花岛 Xcode 构建秘籍:Swift 中的 “Feature Flags” 心法
app·xcode·swift
用户091 天前
SwiftUI Charts 函数绘图完全指南
ios·swiftui·swift
YungFan1 天前
iOS26适配指南之UIColor
ios·swift
HarderCoder1 天前
Swift 6.2 新特性 `@concurrent` 完全导读
swift
HarderCoder1 天前
Swift 里的“橡皮擦”与“标签”——搞懂 existentials 与 primary associated type
swift
权咚2 天前
阿权的开发经验小集
git·ios·xcode