在macOS 10.14中,用户可以选择采用系统范围的亮或暗外观,我需要根据当前模式手动调整一些颜色.
我正在使用 UIViewRepresentable 结构在 SwiftUI 中嵌入一个“使用 Apple 登录”按钮来显示按钮。
import SwiftUI
import UIKit
import AuthenticationServices
final class AppleIDButton: UIViewRepresentable {
typealias UIViewType = UIView
var appleButton = ASAuthorizationAppleIDButton()
func makeUIView(context: UIViewRepresentableContext<AppleIDButton>) -> UIView {
let view = UIView()
view.addSubview(appleButton)
return view
}
func updateUIView(_ uiView: UIView, context: UIViewRepresentableContext<AppleIDButton>) {
appleButton.cornerRadius = 8
}
}
Run Code Online (Sandbox Code Playgroud)
...//这是我的 SwiftUI 文件中的代码
ZStack(alignment: .top) {
VStack(spacing: 0) {
Rectangle()
.frame(width: screenWidth, height: 1)
.foregroundColor(Color("lineGray"))
Rectangle()
.frame(width: screenWidth, height: screenHeight * 0.375)
.foregroundColor(.white)
}
VStack {
HStack { …
Run Code Online (Sandbox Code Playgroud) 如果图像存在,我正在尝试执行代码。问题是我无法捕获空图像调用的状态。结果是我得到一个空图像,但如果可能的话宁愿放置一个占位符图像。
func procImage(inName: String) {
switch (inName) {
case inName:
imageName = inName.lowercased()
default:
imageName = "blank"
}
}
Run Code Online (Sandbox Code Playgroud) 按钮是在故事板中创建的,我想添加一个动作.
self.cancel.action = NSSelectorFromString("cancel:")
func cancel(sender: UIBarButtonItem) ->() {
}
Run Code Online (Sandbox Code Playgroud)
这不起作用.谢谢
swift ×3
ios ×2
swiftui ×2
appearance ×1
image ×1
ios13 ×1
macos ×1
macos-mojave ×1
objective-c ×1
xcode6-beta6 ×1