{"id":15055326,"url":"https://github.com/tomortec/simplecardview-swiftui","last_synced_at":"2025-04-10T03:37:03.059Z","repository":{"id":62457537,"uuid":"484747579","full_name":"Tomortec/SimpleCardView-SwiftUI","owner":"Tomortec","description":"`SimpleCardView-SwiftUI` is a very simple card view written with SwiftUI","archived":false,"fork":false,"pushed_at":"2022-05-04T16:17:03.000Z","size":1685,"stargazers_count":6,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-22T18:47:35.916Z","etag":null,"topics":["card","ios","swift","swiftui","tomortec","ui"],"latest_commit_sha":null,"homepage":"","language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Tomortec.png","metadata":{"files":{"readme":"README-zh.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-04-23T12:56:28.000Z","updated_at":"2024-02-19T19:34:26.000Z","dependencies_parsed_at":"2022-11-02T00:31:24.177Z","dependency_job_id":null,"html_url":"https://github.com/Tomortec/SimpleCardView-SwiftUI","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Tomortec%2FSimpleCardView-SwiftUI","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Tomortec%2FSimpleCardView-SwiftUI/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Tomortec%2FSimpleCardView-SwiftUI/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Tomortec%2FSimpleCardView-SwiftUI/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Tomortec","download_url":"https://codeload.github.com/Tomortec/SimpleCardView-SwiftUI/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248153693,"owners_count":21056482,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["card","ios","swift","swiftui","tomortec","ui"],"created_at":"2024-09-24T21:40:53.646Z","updated_at":"2025-04-10T03:37:03.035Z","avatar_url":"https://github.com/Tomortec.png","language":"Swift","funding_links":[],"categories":[],"sub_categories":[],"readme":"# SimpleCardView-SwiftUI\n\n\u003cimg src=\"./screenshot.png\" alt=\"Banner\" width=\"400\"\u003e\n\n`SimpleCardView-SwiftUI` 是用 SwiftUI 写的小卡片视图\n\n\u003cimg src=\"./demo.gif\" alt=\"Demo\" width=\"200\"\u003e\n\n## CardView 的结构\n\u003cimg src=\"./pic-structure.png\" alt=\"Structure\" width=\"400\"\u003e\n\n## 小示例\n\n``` Swift\nCardView(\n    size: CGSize(width: 150.0, height: 200.0),\n    title: \"Hello World\",\n    cover: {\n        Image(systemName: \"leaf.fill\")\n            .resizable()\n            .foregroundColor(.white)\n            .frame(width: 100.0, height: 100.0)\n    }, detail: {\n        VStack(spacing: 20.0) {\n            Text(\"Sheet\")\n                .font(.largeTitle)\n                .foregroundColor(.white)\n            \n            Image(systemName: \"moon.stars.fill\")\n                .resizable()\n                .scaledToFit()\n                .padding()\n                .foregroundColor(.yellow)\n        }\n        .frame(maxWidth: .infinity, maxHeight: .infinity)\n        .background(.cyan)\n})\n.backgroundColor(colors: [.cyan, .blue])\n```\n\n克隆本仓库，在 `Example` 文件夹执行 `pod install` 后在 `Xcode` 运行示例项目来查看 demo\n\n## 接口\n\n### 初始化\n```swift \ninit(\n    size: CGSize, \n    title: String, \n    titleViewProportion: CGFloat = 1 / 4, // TitleView 的高占 卡片的高 的比例\n    spacing: CGFloat = 0.0, \n    detailViewType: CardDetailsViewType = .sheet, // DetailView 展示的样式\n    detailViewBinding: Binding\u003cBool\u003e? = nil, // 添加一个 `Binding` 来控制 DetailView 的可见性\n    cover: () -\u003e Cover, \n    detail: () -\u003e Detail, \n    onTap action: (() -\u003e ())? = nil\n)\n```\n\n### `BackgroundView` 的方法\n``` swift\n// 设置背景颜色\nfunc backgroundColor(_ color: Color) \n\n// 设置背景的线性渐变颜色\nfunc backgroundColor(colors: [Color], startPoint: UnitPoint = .top, endPoint: UnitPoint = .bottom) \n\n// 设置卡片圆角\nfunc cardCornerRadius(_ radius: CGFloat)\n\n// 设置卡片阴影\nfunc cardShadow(color: Color? = nil, radius: CGFloat, xOffset: CGFloat? = nil, yOffset: CGFloat? = nil)\n```\n\n### `TitleView` 的方法\n```swift\n// 用 `AnyView` 替换 TitleView\nfunc replaceTitleView(with alternativeView: AnyView)\n\n// 设置标题\nfunc title(_ title: String)\n\n// 设置标题字体\nfunc titleFont(_ font: Font)\n\n// 设置标题文本颜色\nfunc titleColor(_ color: Color)\n\n// 设置标题对齐方式\nfunc titleAlignment(_ alignment: HorizontalAlignment)\n\n// 设置标题截取方式\nfunc titleTruncationMode(_ mode: Text.TruncationMode)\n```\n\n执行 Xcode 的 `Product \u003e Build Documentation` 并前往文档中心来查看 `SimpleCardView-SwiftUI` 的更多接口细节\n\n## Swift 版本\n\nSwift \u003e= 5.0\n\n## 安装方法\n\n`SimpleCardView-SwiftUI` 已在 [CocoaPods](https://cocoapods.org)发布。添加下列命令到你的 `Podfile` 来安装 `SimpleCardView-SwiftUI`:\n\n```ruby\npod 'SimpleCardView-SwiftUI'\n\n# 注意：如果您下载的是 0.0.2 版本, 请使用下面的命令重试\n# pod 'SimpleCardView-SwiftUI', :git =\u003e 'https://github.com/Tomortec/SimpleCardView-SwiftUI.git'\n```\n\n## 作者\n\nTomortec, everything@tomortec.com\n\n## License\n\nSimpleCardView-SwiftUI is available under the MIT license. See the LICENSE file for more info.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftomortec%2Fsimplecardview-swiftui","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftomortec%2Fsimplecardview-swiftui","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftomortec%2Fsimplecardview-swiftui/lists"}