小编PAK*_*PAK的帖子

SwiftUI:列表上的渐变背景

有人能告诉我如何在 SwiftUI 列表上添加渐变背景吗?

当前代码:

struct TestView: View {
    var body: some View {
        LinearGradient(gradient: Gradient(colors: [Color.red, Color.purple]), startPoint: .top, endPoint: .bottom)
            .edgesIgnoringSafeArea(.vertical)
            .overlay(
                List {
                    Group {
                        Text("Hallo")
                        Text("World")
                    }
                    .background(Color.blue)
                }
                .background(Color.green)
                .padding(50)
        )
    }
}
Run Code Online (Sandbox Code Playgroud)

当前布局,其中渐变在单元格后面可见。我想让单元格透明以查看下面的渐变。

在此处输入图片说明

谢谢!

ios swift swiftui

8
推荐指数
1
解决办法
3370
查看次数

Swift 3 - 原子布尔值

有人知道如何在 iOS 10 中创建原子布尔值吗?

当前代码:

import UIKit

struct AtomicBoolean {
    fileprivate var val: UInt8 = 0

    /// Sets the value, and returns the previous value.
    /// The test/set is an atomic operation.
    mutating func testAndSet(_ value: Bool) -> Bool {
       if value {
           return OSAtomicTestAndSet(0, &val)
       } else {
           return OSAtomicTestAndClear(0, &val)
       }
    }

    /// Returns the current value of the boolean.
    /// The value may change before this method returns.
    func test() -> Bool {
      return val != 0 …
Run Code Online (Sandbox Code Playgroud)

boolean atomicboolean swift swift3 ios10

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

标签 统计

swift ×2

atomicboolean ×1

boolean ×1

ios ×1

ios10 ×1

swift3 ×1

swiftui ×1