小编Han*_*eer的帖子

SwiftUI - 设置状态栏背景颜色以与导航栏对齐

我正在尝试设置状态栏的背景颜色以使其与导航栏颜色对齐。在 UIKit 中,我会在它下面放置一个视图。在 SwiftUI 中,我尝试使用 aZStack 但是大标题不再起作用。

所以这是我目前没有绿色状态栏的工作状态:

 var body: some View {
        NavigationView {
            
            ScrollView {
                Text("Lol 123 Lol")
                    .foregroundColor(Color.secondary)
                    .padding([.top, .bottom], 16)
                    .padding([.leading,.trailing], 16)
                TwoTextFieldsView(isSecondSecure: true,
                                  firstTextFieldText: username,
                                  secondTextFieldText: password,
                                  firstTextFieldPlaceholder: "Username",
                                  secondTextFieldPlaceholder: "Password")
                    .padding([.leading,.trailing, .bottom], 16)
                
                
                
            }
            .navigationBarTitle("Connect to Lol")
            .onTapGesture {
                self.hideKeyboard()
            }
            
        }
        
    }
Run Code Online (Sandbox Code Playgroud)

它看起来像:

这个

statusbar uinavigationbar ios swift swiftui

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

使用 Apples CryptoKit 在 iOS 和 Kotlin/Java 之间进行跨平台 AES 加密

我想使用 Apples CryptoKit 将加密数据从运行 kotlin 应用程序的服务器发送到 iOS 应用程序。我在初始化AES.GCM.SealedBox和解密数据时遇到问题。总的来说,我不明白 Sealboxstag的用途。

所以首先是 Kotlin 方面:

        fun ByteArray.aesEncrypt(key: ByteArray, iv: ByteArray? = null): ByteArray {
            return aes(this, Cipher.ENCRYPT_MODE, key, iv)
        }
        private fun aes(self: ByteArray, mode: Int, key: ByteArray, iv: ByteArray?): ByteArray{
            val skey = SecretKeySpec(key, "AES")
            val cipher = Cipher.getInstance("AES/GCM/PKCS5Padding")
            println("MODE: ${cipher.algorithm}")
            iv?.let {
                cipher.init(mode, skey, GCMParameterSpec(128, iv))
            }?: run{
                cipher.init(mode, skey)
            }
            val cipherText = ByteArray(cipher.getOutputSize(self.size))
            var ctLength = cipher.update(self, 0, self.size, cipherText, 0)
            ctLength += cipher.doFinal(cipherText, ctLength) …
Run Code Online (Sandbox Code Playgroud)

encryption aes kotlin swift apple-cryptokit

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