1.9K Views
July 14, 24
スライド概要
自己紹介に利用した資料
iOSアプリの開発をしています。 個人アプリも色々あります。 # Type: https://type-markdown.app WebCollector: https://webcollector.app/ Pity: https://freetimepicker.firebaseapp.com
SwiftUIのUI Tips かっくん @fromkk
iPadの擬似 readableContentGuide
import SwiftUI
extension View {
@ViewBuilder
public func contentGuide(_ width: CGFloat = 432) -> some View {
HStack(spacing: 0) {
Spacer(minLength: 0)
self
.frame(maxWidth: width, alignment: .center)
Spacer(minLength: 0)
}
.frame(maxWidth: .infinity)
}
}
グラスグラデーション https://zenn.dev/fromkk/articles/6bde4249650d61
public struct NavigationBarBackgrounView: View {
public init() {}
let maxHeight: CGFloat = 160
public var body: some View {
ZStack {
Color.clear
.background(.regularMaterial)
.frame(maxWidth: .infinity, maxHeight: maxHeight)
LinearGradient(
gradient: Gradient(colors: [.black.opacity(0), .black]),
startPoint: .top,
endPoint: .bottom
)
.blendMode(.destinationOut)
.frame(maxWidth: .infinity, maxHeight: maxHeight)
}
.compositingGroup()
.frame(maxHeight: maxHeight)
.ignoresSafeArea()
.allowsHitTesting(false)
}
}
extension View {
@ViewBuilder
public func blurNavigationBar() -> some View {
ZStack(alignment: .top) {
self
NavigationBarBackgrounView()
}
}