macos - SwiftUI macOS MenuButton 标签问题
问题描述
我在我的 macOS 应用程序中使用 MenuButton。MenuButton 将标签和内容作为参数,效果很好。苹果给出以下声明
struct MenuButton<Label, Content> where Label : View, Content : View
我正在尝试使用带有两个Image
和一个文本作为标签的视图,如下所示:
MenuButton(label: Title(name: "Title"), content: {
...
})
.menuButtonStyle(BorderlessButtonMenuButtonStyle())
标题声明如下:
struct Title: View {
var name : String = ""
var body: some View {
HStack
{
Text(self.name)
.foregroundColor(Color("c_SecondaryColor"))
Image("PickerIcon") //<< This is visible
Image("PickerIcon2") //<< This is NOT visible - can not use two Image
}
}
}
在标题中我有两个图像。但是,只显示了一个。为什么标签只允许一个图像,即使它被声明为View
类型。
解决方案
推荐阅读
- asp.net-mvc - MVC 中 RedirectToAction 的 ModelState 验证
- ms-access - Access 为我带来所选列中的随机记录
- android - How to automatically update mobile app (from Managed Google Play) with Microsoft Intune
- java - Multiple Inheritance using Anonymous class in Java
- javascript - 开发 Office 加载项时“‘应用程序’未定义”
- r - 在 R 中抓取数据
- rest - ArcGIS REST API - 如何查看 geoJSON 结果?
- algorithm - 从随机字节派生密码字符串
- php - PHP 输出缓冲抛出警告
- arrays - 将数组映射到对象列表 kotlin