小编vdo*_*tup的帖子

SwiftUI 菜单内容以 RTL 语言翻转

在project.pbxproj中,我将developmentRegion更改为ar,以在整个应用程序中强制使用阿拉伯语言和RTL布局,除了本例中的菜单视图内容外,一切看起来都很好:

\n
import SwiftUI\n\nstruct ContentView: View {\n    \n    @State private var selectedTime: Int = 0\n    \n    var body: some View {\n        Form {\n            Picker("", selection: $selectedTime) {\n                Text("\xd8\xb5\xd8\xa8\xd8\xa7\xd8\xad\xd8\xa7\xd9\x8b").tag(0)\n                Text("\xd9\x85\xd8\xb3\xd8\xa7\xd8\xa1\xd9\x8b").tag(1)\n            }\n            .labelsHidden()\n            .pickerStyle(SegmentedPickerStyle())\n            Menu {\n                Button("\xd8\xa7\xd9\x84\xd8\xb3\xd8\xa8\xd8\xaa", action: {})\n                Button("\xd8\xa7\xd9\x84\xd8\xa3\xd8\xad\xd8\xaf", action: {})\n                Button("\xd8\xa7\xd9\x84\xd8\xa7\xd8\xab\xd9\x86\xd9\x8a\xd9\x86", action: {})\n                Button("\xd8\xa7\xd9\x84\xd8\xab\xd9\x84\xd8\xa7\xd8\xab\xd8\xa7\xd8\xa1", action: {})\n                Button("\xd8\xa7\xd9\x84\xd8\xa7\xd8\xb1\xd8\xa8\xd8\xb9\xd8\xa7\xd8\xa1", action: {})\n                Button("\xd8\xa7\xd9\x84\xd8\xae\xd9\x85\xd9\x8a\xd8\xb3", action: {})\n                Button("\xd8\xa7\xd9\x84\xd8\xac\xd9\x85\xd8\xb9\xd8\xa9", action: {})\n            } label: {\n                Label("\xd8\xa7\xd9\x84\xd9\x8a\xd9\x88\xd9\x85", systemImage: "calendar")\n            }\n        }\n    }\n}\n\nstruct ContentView_Previews: PreviewProvider {\n    static var previews: some View {\n        ContentView()\n            .preferredColorScheme(.dark)\n    }\n}\n
Run Code Online (Sandbox Code Playgroud)\n

菜单内的按钮标签被翻转

\n

菜单按钮标签翻转

\n …

xcode menu ios swift swiftui

6
推荐指数
1
解决办法
1188
查看次数

SwiftUI 3 MacOs Table单选并双击打开工作表

import SwiftUI

struct ContentView: View {
    
    @State private var items: [ItemModel] = Array(0...100).map { ItemModel(id: $0, title: "item \($0)", age: $0) }
    @State private var selection = Set<ItemModel.ID>()
    @State private var sorting = [KeyPathComparator(\ItemModel.age)]
    
    var body: some View {
        Table(items, selection: $selection, sortOrder: $sorting) {
            TableColumn("id", value: \.id) { Text("\($0.id)") }
            TableColumn("title", value: \.title)
            TableColumn("age", value: \.age) { Text("\($0.age)") }
        }
        .onChange(of: sorting) {
            items.sort(using: $0)
        }
        .font(.caption)
        .frame(width: 960, height: 540)
    }
}

struct ItemModel: Identifiable {
    var id: …
Run Code Online (Sandbox Code Playgroud)

macos xcode swiftui xcode13

5
推荐指数
2
解决办法
4508
查看次数

Swift 包管理器仅添加选定的库

// swift-tools-version:5.5
import PackageDescription
    
let package = Package(
    name: "PKG",
    platforms: [.iOS(.v15)],
    products: [
        .library(name: "Lib1", targets: ["Lib1"]),
        .library(name: "Lib2", targets: ["Lib2"]),
        .library(name: "Lib3", targets: ["Lib3"]),
    ],
    dependencies: [
    ],
    targets: [
        .target(name: "Lib1", dependencies: []),
        .target(name: "Lib2", dependencies: []),
        .target(name: "Lib3", dependencies: []),
    ]
)
Run Code Online (Sandbox Code Playgroud)

我正在创建一个包含多个产品的包,我将其上传到github以在我的项目中的SPM中使用它,

它让我选择要添加到我的项目中的库,这就是我想要的,但无论我选择什么,它都会将所有库及其文件带到我的项目中,这是它的工作原理吗?或者我可以让它只下载选定的库及其依赖项吗?

谢谢

xcode github package swift swift-package-manager

5
推荐指数
1
解决办法
1692
查看次数

SwiftUI Xcode 12.3 无法更改工具栏中的按钮大小

struct ContentView: View {
    var body: some View {
        NavigationView {
            List {
                Text("Hi")
            }
            .navigationBarTitleDisplayMode(.inline)
            .toolbar {
                ToolbarItem(placement: .principal) {
                    Text("Title")
                        .font(.headline)
                }
                ToolbarItem(placement: .navigationBarLeading) {
                    Button(action: {}) {
                        Image(systemName: "person.circle")
                            .font(.largeTitle)
                    }
                }
            }
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

.font(.largeTitle)Image有没有影响,只有当我使用一个按钮里面。

这是一个错误还是我做错了什么?

ios swift swiftui

4
推荐指数
1
解决办法
833
查看次数

标签 统计

swift ×3

swiftui ×3

xcode ×3

ios ×2

github ×1

macos ×1

menu ×1

package ×1

swift-package-manager ×1

xcode13 ×1